# Beginner struggling \_all\_ the data \[edited\]

**URL:** <https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98>\
**Category:** Help\
**Tags:** python, sdk\
**Created:** [December 14, 2021, 8:34pm UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98 "2021-12-14T20:34:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NanMelch](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@NanMelch](https://forum.frame.io/u/NanMelch)\
**Post date:** [December 14, 2021, 8:34pm UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98/1 "2021-12-14T20:34:15Z")

</div>

Hi!  
I’m still relatively new new to programming and slowly making my way through the API documentation. My end goal is to create a CSV with a list of teams, projects, folders, assets, and links.

> I feel a bit stuck in a loop at the beginning of the API however with finding the `root_asset_id`. I’ve started with the “[https://api.frame.io/v2/me](https://api.frame.io/v2/me)” and the get account examples on the API. I’m able to pull the account\_id from there, but when moving forward to teams I’m confused about the
> 
> query = {  
> “include”: “user\_role”  
> }
> 
> part and what results to be expecting. Any guidance would be appreciated.
> 
> Nancy

I was able to push through my initial troubles – I was using the wrong `account_id`. However, now I’m at the point where I’d like to get all of the projects for the teams. I wrote this loop

```auto
projects_in_a_team = []
for n in range(len(teamsdata)):
     team_id = teamsdata[n]['id']
     url4 = "https://api.frame.io/v2/teams/" + team_id + "/projects"
     response4 = requests.get(url4, headers=headers)
     projectdata = response4.json()
     projects_in_a_team.append(projectdata)

```

but as you an imagine it’s sluggish and quite long. Is there a more efficient way to get all the projects on a team?

---

<div class="post-metadata">

**Author:** ![jhodges](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.frame.io/jhodges/32/3_2.png) [@jhodges](https://forum.frame.io/u/jhodges)\
**Post date:** [December 16, 2021, 1:25am UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98/2 "2021-12-16T01:25:17Z")

</div>

Looks like you’re writing this in Python which means you should definitely check out `frameioclient`, our Python SDK - [frameioclient · PyPI](https://pypi.org/project/frameioclient/).

The way our API is architected, you’re always going to have to navigate resources canonically, for example: Account \> Team \> Project - like you are here. What you could do to make this quicker though is to increase the page size from the default of `50` to say, `1,000` which should at least mean less API calls. Looking at your code I also don’t see any handling of pagination, but you can learn more about that [here](https://developer.frame.io/docs/getting-started/key-concepts#pagination).

Lastly, here’s a trick you can do with your code to make it slightly more concise if you want:

```auto
for i, team enumerate(teamsdata):
     team_id = team['id']
     url4 = "https://api.frame.io/v2/teams/" + team_id + "/projects"
     response4 = requests.get(url4, headers=headers)
     projectdata = response4.json()
     projects_in_a_team.append(projectdata)

```

---

<div class="post-metadata">

**Author:** ![NanMelch](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@NanMelch](https://forum.frame.io/u/NanMelch)\
**Post date:** [December 21, 2021, 12:57am UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98/3 "2021-12-21T00:57:17Z")

</div>

Thanks. That helped a lot.  
I’m still struggling with the `frameioclient` a bit.  
I’ve gotten through the asset tree and am at the folder level. In the examples on github (as you know) there is a function that does what I’m looking to do:

```auto
def scrape_asset_data(client, asset_id, asset_list):
    """
    Takes an initialized client and an asset_id representing a position in a directory tree.
    Recursively builds a list of assets within the tree. Returns a list of dicts.
    """
    assets = client.get_asset_children(asset_id)

    for asset in assets:
        # Recurse through folders but skip the empty ones
        if asset['type'] == "folder" and asset != []:
            # Include non-empty folders in the list of scraped assets
            asset_list.append(asset)
            scrape_asset_data(client, asset['id'], asset_list)

        if asset['type'] == "file":
            asset_list.append(asset)

        if asset['type'] == "version_stack":
            # Read about version stacks: https://docs.frame.io/docs/managing-version-stacks
            versions = client.get_asset_children(asset['id'])
            asset_list.append(asset)
            for v_asset in versions:
                asset_list.append(v_asset)

    return asset_list

```

But when I try to follow that, the `.get_asset_children` returns undefined. I had been using, seen in my original post, the `requests.get(url...) ` method. I think I’m missing how to adapt the `request.get(url...)` with `'/children?type=folder` and `/children?type = file` into the function for scraping through a folder for subfolders and files.

Am I missing an import module? Or do I just need to loop through every folder separately? I’ll keep trying, just thought I’d ask the forum for any advice!

---

<div class="post-metadata">

**Author:** ![jhodges](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.frame.io/jhodges/32/3_2.png) [@jhodges](https://forum.frame.io/u/jhodges)\
**Post date:** [December 21, 2021, 5:29pm UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98/4 "2021-12-21T17:29:20Z")

</div>

Okay, so the issue is that this example is out-dated and won’t work with this version of the SDK! Sorry about the confusion here.

If you want to use this code as is, then you’ll need to use a version of `frameioclient` \< 1.0.0.

I will quickly try and update this so that it runs using any version of the SDK \> 1.0.0 though.

---

<div class="post-metadata">

**Author:** ![jhodges](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.frame.io/jhodges/32/3_2.png) [@jhodges](https://forum.frame.io/u/jhodges)\
**Post date:** [December 21, 2021, 6:11pm UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98/5 "2021-12-21T18:11:13Z")

</div>

Just finished a big update to the example `asset_scraper.py` which you can find [here](https://github.com/Frameio/python-frameio-client/blob/develop/examples/assets/asset_scraper.py), it’s now fully typed and fully functional using the latest version of the Python SDK!

---

<div class="post-metadata">

**Author:** ![NanMelch](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@NanMelch](https://forum.frame.io/u/NanMelch)\
**Post date:** [December 21, 2021, 7:07pm UTC](https://forum.frame.io/t/beginner-struggling-all-the-data-edited/98/6 "2021-12-21T19:07:39Z")

</div>

Oh goodness, thanks so much!
