DEV Community

Cover image for What resources help you to learn a new API?
Andy Piper
Andy Piper

Posted on

What resources help you to learn a new API?

In my day job, when I'm not learning things by reading and sharing here on DEV, I'm a developer advocate at Twitter. I've been doing this for quite a long time now, and I recognise that while I'm always learning for myself, I don't always stop to think about how other people learn.

I know that personally, I learn best from getting started guides, example code that makes sense, and the ability to "play with" an API using some kind of explorer or command line. I do not usually get so much from videos (but I love to take part in making them!).

How do YOU learn to use new APIs?

The more specific question / broader background...

In November, we launched Twitter API v2, which is a whole new way to access Twitter data, based on the OpenAPI specification, and with a more modern experience than v1.1 (which is around 11 years old - pretty rare for an API to last that long without major changes). We've hosted some Twitch streams and Twitter Spaces to talk about it.

We have documentation, a Postman Collection, and sample code.

GitHub logo twitterdev / Twitter-API-v2-sample-code

Sample code for the Twitter API v2 endpoints

Twitter API v2 sample code v2

Sample code for the Twitter API v2 endpoints Individual API features have folders where you can find examples of usage in several coding languages (Java, Node.js, Python, R, and Ruby).

Prerequisites

Using the code samples

In order to run the samples in this repository you will need to set up some environment variables. You can find your credentials and bearer token in the App inside of your Project in the dashboard of the developer portal.

For OAuth 1.0a samples, you will need to export your consumer key and secret in your terminal. Be sure to replace <your_consumer_key> and <your_consumer_secret> with your own credentials without the < >.

export CONSUMER_KEY='<your_consumer_key>'
export CONSUMER_SECRET='<your_consumer_secret>'
Enter fullscreen mode Exit fullscreen mode

For samples which use bearer…

If you had the chance to request an educational resource about the Twitter API, what would you ask for? Tutorials, videos, Twitch, code? Any particular topic you want to know more about? Should we provide code in different languages - which ones, and why? Let me know in the discussion below, or follow me on Twitter and Tweet me a suggestion!

Top comments (16)

Collapse
 
thelifeofrishi profile image
Rishi Mohan 🐼

Twitter API's documentation is pretty straightforward and elaborative. In the start it was slightly complicated to understand but after knowing how the API works it was easy to follow. I learnt to use v1.1 and v2 endpoints from Twitter docs only :)

Collapse
 
andypiper profile image
Andy Piper

That's good to know, thank you! Did you use any existing code libraries to work with the v2 API, or did you build directly against the API endpoints for yourself?

Collapse
 
thelifeofrishi profile image
Rishi Mohan 🐼

Yes, I'm using a third-party node library to simplify making calls. This for v2 npmjs.com/package/twitter-api-v2 and Twitjs for v1 endpoints.

I read somewhere that your team is also working on first party libraries, that would be awesome! Also are there plans for Twitter Text npmjs.com/package/twitter-text but for v2 endpoints? I'm currently working on same and planning to open-source, just want to know if you guys are also working on it.

Thread Thread
 
andypiper profile image
Andy Piper • Edited

We've certainly been thinking about building some libraries. The challenge is identifying which languages are most commonly used (I note that you're using JS). Definitely keep an eye on our news here. The community has created some really good libraries as well, as you have discovered.

For twitter-text, there should be no need for a different version - it is a text tokenizer, and the format of the text contents of Tweets themselves have not changed between v1.1 and v2, so the same logic will work. Let us know via the GitHub issues on that repo if there are specific questions about it (that comes from Twitter Engineering internally, rather than from our DevRel team, but we work together on things like this)

Thread Thread
 
thelifeofrishi profile image
Rishi Mohan 🐼

Got it, thanks!

Collapse
 
andrewbaisden profile image
Andrew Baisden

The official documentation works for me.

Collapse
 
dylanlacey profile image
Dylan Lacey

I really like flow diagrams. Show me what I'll need to do to get a specific thing working and I'm much happier.

Collapse
 
andypiper profile image
Andy Piper

Interesting, yes! I wonder if the new Mermaid support on GitHub Markdown will see more of these being used.

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

A game to apply and use your API services like Twilio quest. Quickstart tutorials that includes both video and example is good.

Collapse
 
andypiper profile image
Andy Piper

Nice to hear that you've enjoyed things like Twilio Quest 🛡 I think Salesforce have done things along those lines before as well. It can be nice to have a sense of accomplishment as you progress through getting familiar with an API, I get that for sure. Thanks!

Collapse
 
andypiper profile image
Andy Piper

I think there are probably ways to enhance the Postman resources to go in this kind of direction, as well. I'll think about that.

Collapse
 
leob profile image
leob

Docs, a getting started guide with examples, API reference ... that's it really.

Collapse
 
andypiper profile image
Andy Piper

Do you often build directly on top of the “raw” (JSON+HTTP) API, or look for and use a library?

Collapse
 
leob profile image
leob

If there's a library available for my target programming language, then yeah I'd probably use that library rather than going "low level" (REST/HTTP/JSON).

Collapse
 
codewithpom profile image
Padmashree Jha

I love twitter API because using it I automate my tweets for 5am morning and my friends think that I am so punctual 😎😎 and I use tweepy python library which makes it even easier.

Collapse
 
devfranpr profile image
DevFranPR

With a good documentation is enough. But if you have the option to test all the functions in a sandbox is superb.