```yaml
product: AlterLab
title: "Parse Instagram connections.json (Followers/Following) | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/answers/parse-instagram-connections-json
```

# Parsing Instagram's connections.json Followers and Following Files

## Short answer

### How do you parse the followers and following files in an Instagram data download?

Request your account data in JSON format, unzip it and open the connections folder. The followers and following files list entries whose string_list_data holds the username in value and a timestamp. Load both with Python's json module, collect the usernames into sets and compare them to find accounts that do not follow back.

## Step by step

1. 1
   ### Download your data as JSON
   In the account settings, request a download of your information and choose JSON rather than HTML.
2. 2
   ### Find the connection files
   Inside the archive, open connections/followers_and_following/. Followers may be split across several numbered files.
3. 3
   ### Extract usernames
   Each entry has a string_list_data list; the username is in its value field and the follow time in timestamp.
4. 4
   ### Compare the sets
   Subtract the followers set from the following set to see who does not follow you back.

## Example

Python

```
import json
from pathlib import Path

base = Path("connections/followers_and_following")

def usernames(entries) -> set[str]:
    return {item["value"] for e in entries for item in e["string_list_data"]}

followers = set()
for f in base.glob("followers*.json"):
    followers |= usernames(json.loads(f.read_text()))

following = usernames(
    json.loads((base / "following.json").read_text())["relationships_following"]
)
print(sorted(following - followers))
```

## Frequently Asked Questions

### Why does my file have a different structure?

The export format changes from time to time. Print the top-level keys first; following is usually wrapped in a relationships_following key while followers files are plain lists.

### Is this data current?

It is a snapshot from the moment the export was generated. Request a new download to compare changes over time.

## Read the full guide

[Working with data in Python](https://alterlab.io/how-to/scrape-data-python)

## Related answers

[Serving JSON Data from GitHub Pages](https://alterlab.io/answers/serve-json-from-github-pages)[Saving an Article's Like and Share Counts to a Database](https://alterlab.io/answers/save-article-likes-shares-to-database)

## Try it with AlterLab

Send a URL, get the page back as HTML, markdown or JSON. Rendering, proxy rotation and retries are handled for you.

[View API docs](https://alterlab.io/docs/api/rest)

## Your first scrape. Sixty seconds.

Up to 5,000 free requests — about 5,000 direct fetch, 500 managed sessions or 250 full browser rendering requests. No credit card. 
Just a POST request.

terminal

curl -X POST https://api.alterlab.io/v1/scrape \

-H "X-API-Key: YOUR_KEY" \

-H "Content-Type: application/json" \

-d '{"url": "https://example.com", "formats": ["markdown"]}'

[Start building free](https://alterlab.io/signin)

No credit card required · Up to 5,000 free requests (about 5,000 direct fetch, 500 managed sessions or 250 full browser rendering requests) · Balance never expires