Create Section using Python API


#1

I am trying to create to create a new project, create several sections, and then create several tasks in each one of the sections.

The Python API was updated recently with some updates to section functionality, but the api.json file in the repo is 3 years old, so I’m having some trouble figuring out the actual methods to call (or if it’s even possible).

If anyone knows how to do this (or if there’s more Python documentation that I’m missing), please let me know. The API documentation at https://asana.com/developers/api-reference/sections has examples, but they’re all in bash. I’ve tried figuring out how to translate it to Python, but no luck so far.


#2

The Python API: https://github.com/Asana/python-asana


#3

Hey @Daniel12,

Thanks for reaching out. I hope you’ve been able to get unblocked using the Python client library. As you posted above, you can find the code for all of our client libraries on GitHub. For Python specifically, you can find all of the Python methods in the gen file: https://github.com/Asana/python-asana/tree/master/asana/resources/gen

There are also a few examples in this folder: https://github.com/Asana/python-asana/tree/master/examples

Let us know if you need any more help getting started.

Cheers!
Jeff


#4

@Jeff_Schneider — thanks for the reply!

The gen file you linked is spectacular, I didn’t realize that was there as reference for what methods were made available (maybe link it in the readme or something? unless I missed something obvious). I ended up building my own methods using the python requests library, but this looks awesome.

Thanks!


#5

Hey @Daniel12, sorry that you ended up doing extra work! It is definitely not obvious that you need to find the methods buried deep within the client library. I agree that it would be helpful to mention this in the readme and/or the API docs. We’ll make sure to do so next time we update this client library.


#6

Since Hacker News launched their official API, I started working on Python wrapper for it. API v0 is fairly simple, you send a GET request with hacker news story’s ID or user id, it returns data in JSON.

Here I do the same using requests library and return the specific object as Item for a news story or comment and User for a user on Hacker News.