Example of using a GraphQL service to explore the Twitter API
A great way to explore the Twitter API and returned data, without worrying about authorization or local setup. Just add a query in the explorer and hit run.
The GraphQL Hub website has an interactive GraphiQL service which allows access to Gitub, Twitter, Giphy and other APIs in the browser without authorization.
There are some convenient "playground" links to explore on the homepage:
The example in this gist covers how to get Twitter data from the service. The example covers the functionality the service is capable of:
- lookup a tweet by ID
- lookup a user by ID or screen name
- search tweets by query e.g. hashtag search.
Look at the other files in this gist or follow the link below:
https://www.graphqlhub.com/playground?query...
Ideas to improve on the query:
- Repeat the user section or search section for additional lookups
- Increase the count for the search
- use variables to make the query more flexible then set the values using the parameters pane at the bottom. That needs to valid JSON.
Note that the functionality on the service is very limited.
You cannot do paging for higher volume of search tweets. There are a lot of things in the full Twitter API which are not covered here. Also the fields are limited - you can get retweet count but not favorites for example.
And it feels buggy:
- I found
url
was not set in search when it was fine in user. - Adding retweet-related fields reduced the number of tweets.
- It did not return a tweet which a known ID while another tweet ID was fine.