General documentation / cheat sheets for various languages and services

twitter

Data structures

Tweets

Tweets look like this (this is a tweet of mine, so I can repost it here):

{
  "created_at": "Mon Nov 03 08:17:23 +0000 2014",
  "id": 529185556337397760, "id_str": "529185556337397760",
  "text": "Late night Twitter API observations: statuses/sample maxes out around 36 tweets / second; statuses/filter?track=twitter: 200 t/s",
  "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
  "truncated": false,
  "in_reply_to_status_id": null, "in_reply_to_status_id_str": null,
  "in_reply_to_user_id": null, "in_reply_to_user_id_str": null,
  "in_reply_to_screen_name": null,
  "user": {
    "id": 14380188, "id_str": "14380188",
    "name": "chbrown", "screen_name": "chbrown",
    "location": "here", "profile_location": null,
    "description": "linguist, programmer, photographer",
    "url": "http://t.co/M8vkS2APeh",
    "entities": {
      "url": {"urls": [{
        "url": "http://t.co/M8vkS2APeh",
        "expanded_url": "http://henrian.com",
        "display_url": "henrian.com",
        "indices": [0, 22]
      }]},
      "description": {"urls": []}
    },
    "protected": false,
    "followers_count": 232, "friends_count": 445,
    "listed_count": 15, "favourites_count": 89,
    "created_at": "Mon Apr 14 02:13:55 +0000 2008",
    "utc_offset": -21600,
    "time_zone": "Central Time (US & Canada)",
    "geo_enabled": false,
    "verified": false,
    "statuses_count": 615,
    "lang": "en",
    "contributors_enabled": false,
    "is_translator": false, "is_translation_enabled": false,
    "profile_background_color": "1F1D21",
    "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/311715039/twitter-bg.jpg",
    "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/311715039/twitter-bg.jpg",
    "profile_background_tile": true,
    "profile_image_url": "http://pbs.twimg.com/profile_images/470254057186029568/Zwaknppy_normal.jpeg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/470254057186029568/Zwaknppy_normal.jpeg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/14380188/1400951912",
    "profile_link_color": "3B87EB",
    "profile_sidebar_border_color": "FC35C4", "profile_sidebar_fill_color": "1F1D21",
    "profile_text_color": "FFFF4A",
    "profile_use_background_image": true,
    "default_profile": false, "default_profile_image": false,
    "following": false, "follow_request_sent": false,
    "notifications": false
  },
  "geo": null, "coordinates": null, "place": null,
  "contributors": null,
  "retweet_count": 0, "favorite_count": 0,
  "entities": {"hashtags": [], "symbols": [], "user_mentions": [], "urls": []},
  "favorited": false, "retweeted": false,
  "lang": "en"
}

Users

Users look like this (this is me, crawled on 2014-12-13 14:46:51 CST, so I can repost it here):

{
  "id": 14380188, "id_str": "14380188",
  "name": "chbrown", "screen_name": "chbrown",
  "location": "here", "profile_location": null,
  "description": "linguist, programmer, photographer",
  "url": "http://t.co/M8vkS2APeh",
  "entities": {
    "url": {"urls": [{
      "url": "http://t.co/M8vkS2APeh",
      "expanded_url": "http://henrian.com",
      "display_url": "henrian.com",
      "indices": [0, 22]
    }]},
    "description": {"urls": []}
  },
  "protected": false,
  "followers_count": 237,
  "friends_count": 449,
  "listed_count": 15,
  "created_at": "Mon Apr 14 02:13:55 +0000 2008",
  "favourites_count": 96,
  "utc_offset": -21600,
  "time_zone": "Central Time (US & Canada)",
  "geo_enabled": false,
  "verified": false,
  "statuses_count": 629,
  "lang": "en",
  "status": {
    "created_at": "Sat Dec 13 19:04:04 +0000 2014",
    "id": 543843813911842800, "id_str": "543843813911842816",
    "text": "I don't know exactly what kind of deal Mozilla and Yahoo worked out, but I get a very icky feeling from it.",
    "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
    "truncated": false,
    "in_reply_to_status_id": null, "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null, "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "geo": null, "coordinates": null, "place": null,
    "contributors": null,
    "retweet_count": 0, "favorite_count": 0,
    "entities": {"hashtags": [], "symbols": [], "user_mentions": [], "urls": []},
    "favorited": false, "retweeted": false,
    "lang": "en"
  },
  "contributors_enabled": false,
  "is_translator": false, "is_translation_enabled": false,
  "profile_background_color": "1F1D21",
  "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/311715039/twitter-bg.jpg",
  "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/311715039/twitter-bg.jpg",
  "profile_background_tile": true,
  "profile_image_url": "http://pbs.twimg.com/profile_images/470254057186029568/Zwaknppy_normal.jpeg",
  "profile_image_url_https": "https://pbs.twimg.com/profile_images/470254057186029568/Zwaknppy_normal.jpeg",
  "profile_banner_url": "https://pbs.twimg.com/profile_banners/14380188/1400951912",
  "profile_link_color": "3B87EB",
  "profile_sidebar_border_color": "FC35C4", "profile_sidebar_fill_color": "1F1D21",
  "profile_text_color": "FFFF4A",
  "profile_use_background_image": true,
  "default_profile": false, "default_profile_image": false,
  "following": false, "follow_request_sent": false,
  "notifications": false
}

Streaming maintenance messages

Beyond tweets and empty lines (keep-alive signals), streaming endpoints can produce several other types of messages:

Limits

{
  "limit": {
    "track": 1000
  }
}

Disconnects

{
  "disconnect": {
    "code": 4,
    "stream_name": ...,
    "reason": "The client was reading too slowly and was disconnected by the server."
  }
}

(Stall) warnings

{
  "warning": {
    "code": "FALLING_BEHIND",
    "message": "Your connection is falling behind and messages are being queued for delivery to you. Your queue is now over 60% full. You will be disconnected when the queue is full.",
    "percent_full": 60
  }
}

Deletes

{
  "delete": {
    "status": {
      "id": 534948377117210840, "id_str": "534948377117210840",
      "user_id": 2413224391, "user_id_str": "2413224391"
    },
    "timestamp_ms": "1416376606621"
  }
}

Location deletions

{
  "scrub_geo": {
    "user_id": 2413224391, "user_id_str": "2413224391",
    "up_to_status_id": 534948377117210840, "up_to_status_id_str": "534948377117210840"
  }
}

Status withheld notices

{
  "status_withheld": {
    "id": 1234567890,
    "user_id": 123456,
    "withheld_in_countries": ["DE", "AR"]
  }
}

User withheld notices

{
  "user_withheld": {
    "id": 123456,
    "withheld_in_countries": ["DE", "AR"]
  }
}

User update

{
  "created_at": "Tue Aug 06 02:23:21 +0000 2013",
  "source": {
    ...
  },
  "target": {
    ...
  },
  "event": "user_update"
}