Code Monkey home page Code Monkey logo

twitter-api-v2-sample-code's Introduction

Twitter API v2 sample code v2

Sample code for early access of the new v2 endpoints (Python, Java, Ruby, and Node.js). Each available endpoint has a folder where you can find sample code.

Getting Started

Using the code samples

In order to run the code samples in this repository you will need to create environment variables. You can find your credentials which now includes your 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>'

For samples which use bearer token authentication, you will need to export your bearer token. Be sure to replace <your_bearer_token> with your own bearer token without the < >.

export 'BEARER_TOKEN'='<your_bearer_token>'

Python environment set up

You will need to have Python 3 installed to run this code. All Python samples except Tweet-Lookup/get_tweets_with_user_context.py and User-Lookup/get_users_with_user_context.py use requests==2.24.0 which uses requests-oauthlib==1.3.0.

You can pip install these packages as follows:

pip install requests
pip install requests-oauthlib

Ruby environment set up

You will need to have Ruby (recommended: >= 2.0.0) installed in order to run the code. The Ruby examples use typheous as the HTTP client, which needs to be gem installed. For the Tweet and User lookup with user context requests, you'll need to install the oauth gem (see below).

gem install typheous
gem install oauth

JavaScript (Node.js) environment set up

You will need to have Node.js installed to run this code. All Node.js examples use needle as the HTTP client, which needs to be npm installed. For the Tweet and User lookup with user context requests, you'll need to install the got and oauth-1.0a packages.

npm install needle
npm install got
npm install oauth-1.0a

Java environment set up

If you use Homebrew, you can install a Java runtime using:

brew cask install java

Prerequisites

Support

Contributing

We welcome pull requests that add meaningful additions to these code samples, particularly for languages that are not yet represented here.

We feel that a welcoming community is important and we ask that you follow Twitter's Open Source Code of Conduct in all interactions with the community.

License

Copyright 2020 Twitter, Inc.

Licensed under the Apache License, Version 2.0: https://www.apache.org/licenses/LICENSE-2.0

twitter-api-v2-sample-code's People

Contributors

andypiper avatar jimmoffitt avatar ajayhubs avatar viktor992 avatar iamdaniele avatar ethanjwright avatar sparack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.