Skip to content

Chainlink external adapter for getting users who have retweeted. View it on the LinkPool market!

Notifications You must be signed in to change notification settings

Ian-Bright/retweet-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chainink External Retweet Adapter

This external adapter is used to verify whether or not a specified twitter user has retweeted a tweet. It takes two parameters, "userid" and "tweetid", and returns true or false based on whether or not the user has retweeted the specific tweet.

Input Params

  • userid: The id of a specific twitter user
  • tweetid: The id of a specific tweet

Output

{
 "jobRunID": "1",
 "data": {
  "userid": "1234567",
  "tweetid": "1234567891011"
 },
 "result": true,
 "statusCode": 200
}

Install Locally

Install dependencies:

yarn

Test

Run the local tests:

yarn test

Natively run the application (defaults to port 8080):

Run

yarn start

Call the external adapter/API server

curl -X POST -H "content-type:application/json" "http://localhost:8080/" --data '{ "id": 0, "data": { "userid": "123456", "tweetid": "12345678910" } }'

AWS Lambda Setup

After installing locally:

Create the zip

zip -r external-adapter.zip .

Install

  • In Lambda Functions, create function
  • On the Create function page:
    • Give the function a name
    • Use Node.js 12.x for the runtime
    • Choose an existing role or create a new one
    • Click Create Function
  • Under Function code, select "Upload a .zip file" from the Code entry type drop-down
  • Click Upload and select the external-adapter.zip file
  • Handler:
    • index.handler for REST API Gateways
    • index.handlerv2 for HTTP API Gateways
  • Add the environment variable (repeat for all environment variables):
    • Key: API_KEY
    • Value: Your_API_key
  • Save

To Set Up an API Gateway (HTTP API)

If using a HTTP API Gateway, Lambda's built-in Test will fail, but you will be able to externally call the function successfully.

  • Click Add Trigger
  • Select API Gateway in Trigger configuration
  • Under API, click Create an API
  • Choose HTTP API
  • Select the security for the API
  • Click Add

To Set Up an API Gateway (REST API)

If using a REST API Gateway, you will need to disable the Lambda proxy integration for Lambda-based adapter to function.

  • Click Add Trigger
  • Select API Gateway in Trigger configuration
  • Under API, click Create an API
  • Choose REST API
  • Select the security for the API
  • Click Add
  • Click the API Gateway trigger
  • Click the name of the trigger (this is a link, a new window opens)
  • Click Integration Request
  • Uncheck Use Lamba Proxy integration
  • Click OK on the two dialogs
  • Return to your function
  • Remove the API Gateway and Save
  • Click Add Trigger and use the same API Gateway
  • Select the deployment stage and security
  • Click Add

About

Chainlink external adapter for getting users who have retweeted. View it on the LinkPool market!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published