App Stream Lifecycle

Create a Stream

Create a Stream for the current token.

Send a JSON document that matches the stream schema with an HTTP header of Content-Type: application/json. Currently, the only keys we use from your JSON will be object_types, type, filter_id and key. If you don’t want to specify a filter, omit filter_id. If you don’t want to specify a key, omit key.

You can create up to 5 streams per App token.

Endpoint

Method URL Token
POST https://api.app.net/streams App

POST Data

A JSON object representing the stream to create. See the stream object for more information. Specify filter_id instead of filter if you want to filter this stream. (Omit the id and endpoint parameters).

Example

to see more complete examples.

curl -X POST -H "Authorization: Bearer <YOUR APP TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    -H "Content-Type: application/json" -d "{
  \"object_types\": [
    \"post\"
  ],
  \"type\": \"long_poll\",
  \"filter_id\": \"1\",
  \"key\": \"rollout_stream\"
}" \
    "https://api.app.net/streams"
{
  "data": {
    "endpoint": "https://stream-channel.app.net...",
    "filter": "...filter object...",
    "id": "1",
    "object_types": [
      "post"
    ],
    "type": "long_poll",
    "key": "rollout_stream"
  },
  "meta": {
    "code": 200
  }
}

Retrieve a Stream

Returns a specific Stream object.

Endpoint

Method URL Token
GET https://api.app.net/streams/{stream_id} App

URL Parameters

Name Description
stream_id The id of the Stream to retrieve.

Example

to see more complete examples.

curl -H "Authorization: Bearer <YOUR APP TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    "https://api.app.net/streams/1"
{
  "data": {
    "endpoint": "https://stream-channel.app.net...",
    "filter": "...filter object...",
    "id": "1",
    "object_types": [
      "post"
    ],
    "type": "long_poll",
    "key": "rollout_stream"
  },
  "meta": {
    "code": 200
  }
}

Get current token’s Streams

Return the Streams for the current token.

Endpoint

Method URL Token
GET https://api.app.net/streams App

Query String Parameters

Name Description
key (Optional) Only retrieve the stream that matches the given key.

Example

to see more complete examples.

curl -H "Authorization: Bearer <YOUR APP TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    "https://api.app.net/streams?key=rollout_stream"
{
  "data": [
    {
      "endpoint": "https://stream-channel.app.net...",
      "filter": "...filter object...",
      "id": "1",
      "object_types": [
        "post"
      ],
      "type": "long_poll",
      "key": "rollout_stream"
    }
  ],
  "meta": {
    "code": 200
  }
}

Update a Stream

Update a Stream. You can update a Stream by PUTing a JSON document that matches the stream schema with an HTTP header of Content-Type: application/json. Currently, the only keys we use from your JSON will be object_types, type, filter_id and key. If you don’t want to specify a filter, omit filter_id. If you don’t want to specify a key, omit key.

Endpoint

Method URL Token
PUT https://api.app.net/streams/{stream_id} App

URL Parameters

Name Description
stream_id The id of the Stream to update.

Example

to see more complete examples.

curl -X PUT -H "Authorization: Bearer <YOUR APP TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    -H "Content-Type: application/json" -d "{
  \"object_types\": [
    \"post\",
    \"star\"
  ],
  \"type\": \"long_poll\",
  \"filter_id\": \"1\",
  \"key\": \"rollout_stream\"
}" \
    "https://api.app.net/streams/1"
{
  "data": {
    "endpoint": "https://stream-channel.app.net...",
    "filter": "...filter object...",
    "id": "1",
    "object_types": [
      "post",
      "star"
    ],
    "type": "long_poll",
    "key": "rollout_stream"
  },
  "meta": {
    "code": 200
  }
}

Delete a Stream

Delete a Stream. The Stream must belong to the current User. It returns the deleted Stream on success.

If you’d like your app stream to be automatically deleted when you disconnect from it, please add the auto_delete=1 query string parameter when you connect to your app stream.

Remember, access tokens can not be passed in a HTTP body for DELETE requests. Please refer to the authentication documentation.

Endpoint

Method URL Token
DELETE https://api.app.net/streams/{stream_id} App

URL Parameters

Name Description
stream_id The id of the Stream to delete.

Example

to see more complete examples.

curl -X DELETE -H "Authorization: Bearer <YOUR APP TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    "https://api.app.net/streams/1"
{
  "data": {
    "endpoint": "https://stream-channel.app.net...",
    "filter": "...filter object...",
    "id": "1",
    "object_types": [
      "post"
    ],
    "type": "long_poll",
    "key": "rollout_stream"
  },
  "meta": {
    "code": 200
  }
}

Delete all of the current user’s Streams

Delete all Streams for the current token. It returns the deleted Streams on success.

Remember, access tokens can not be passed in a HTTP body for DELETE requests. Please refer to the authentication documentation.

Endpoint

Method URL Token
DELETE https://api.app.net/streams App

Example

to see more complete examples.

curl -X DELETE -H "Authorization: Bearer <YOUR APP TOKEN>" -H "X-ADN-Pretty-JSON: 1" \
    "https://api.app.net/streams"
{
  "data": [
    {
      "endpoint": "https://stream-channel.app.net...",
      "filter": "...filter object...",
      "id": "1",
      "object_types": [
        "post"
      ],
      "type": "long_poll",
      "key": "rollout_stream"
    }
  ],
  "meta": {
    "code": 200
  }
}