Twitter binding spec

Detailed documentation on the Twitter binding component

Component format

To setup Twitter binding create a component of type bindings.twitter. See this guide on how to create and apply a binding configuration.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: bindings.twitter
  8. version: v1
  9. metadata:
  10. - name: consumerKey
  11. value: "****" # twitter api consumer key, required
  12. - name: consumerSecret
  13. value: "****" # twitter api consumer secret, required
  14. - name: accessToken
  15. value: "****" # twitter api access token, required
  16. - name: accessSecret
  17. value: "****" # twitter api access secret, required

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Spec metadata fields

FieldRequiredBinding supportDetailsExample
consumerKeyYInput/OutputTwitter API consumer key“conusmerkey”
consumerSecretYInput/OutputTwitter API consumer secret“conusmersecret”
accessTokenYInput/OutputTwitter API access token“accesstoken”
accessSecretYInput/OutputTwitter API access secret“accesssecret”

Binding support

This component supports both input and output binding interfaces.

This component supports output binding with the following operations:

  • get

Input binding

For input binding, where the query matching Tweets are streamed to the user service, the above component has to also include a query:

  1. - name: query
  2. value: "dapr" # your search query, required

Output binding

get

For output binding invocation the user code has to invoke the binding:

  1. POST http://localhost:3500/v1.0/bindings/twitter

Where the payload is:

  1. {
  2. "data": "",
  3. "metadata": {
  4. "query": "twitter-query",
  5. "lang": "optional-language-code",
  6. "result": "valid-result-type"
  7. },
  8. "operation": "get"
  9. }

The metadata parameters are:

  • query - any valid Twitter query (e.g. dapr or dapr AND serverless). See Twitter docs for more details on advanced query formats
  • lang - (optional, default: en) restricts result tweets to the given language using ISO 639-1 language code
  • result - (optional, default: recent) specifies tweet query result type. Valid values include:
    • mixed - both popular and real time results
    • recent - most recent results
    • popular - most popular results

You can see the example of the JSON data that Twitter binding returns here

Related links

Last modified March 18, 2021: Merge pull request #1321 from dapr/aacrawfi/logos (9a399d5)