NAV

Introducción a API de lectura de tweets/fotos de instagram

La api de lectura de tweets o fotos de instagram es muy similar a la API de búsqueda reciente de twitter, así que si tenéis experiencia con ésta, no deberías de tardar nada en implementarla.

Autenticación y configuración

Deberás enviar un parámetro token en cada petición.

Para obtener tu token de usuario, escríbenos a soporte@cool-tabs.com

Ordenación y consulta de datos de tweets/fotos de Instagram

Al consultar los tweets mediante la API, los devolvemos en orden de más recientes a más antiguos. El campo utilizado para ordenar y paginar es el ID del tweet, que Twitter también utiliza (o el ID de Instagram).

Si estoy pidiendo los tweets más recientes que una dada, las devolveremos en orden inverso (en esto nos diferenciamos de twitter).

Si estáis guardando/procesando los tweets de alguna manera, siempre que lleguéis a una participación que ya habéis procesado, podéis dejar de seguir haciendo peticiones a la API porque el resto siempre va a incluir las que ya habéis procesado anteriormente.

La idea es que una vez que se hace el procesamiento inicial de todos los datos existentes, cada vez preguntéis sólo por los nuevos datos que lleguen.

Parámetros

Parámetro Descripción
since_id Devuelve tweets con identificador mayor (más recientes) que ésta (excluído)
max_id Devuelve tweets con identificador menor (más antiguas) que ésta (excluído)

Respuesta

La API devuelve un objeto JSON con 3 posibles encabezados:

Parámetro Descripción
data Array de participantes
pagination Información sobre cómo obtener el resto de participaciones
error {error: {code: codigo_error, message: “Mensaje de error”}}

Ejemplo de paginación en Twitter

Suponemos que cuando empezáis a pedir datos a la API ya hay 5 tweets

curl https://www.cool-tabs.com/api/monitors/1.json?token=xxx&limit=3&summary=true


{
  "data": [
    {
      "id_str": "790421089738424320",
      "text": "#rockclimbing #bouldering @ Desert Rocks Indoor Climbing Gym https://t.co/6ZWnCunoGW",
      "hashtags": [
        "rockclimbing",
        "bouldering"
      ],
      "source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
      "created_time": "2016-10-24T05:14:07.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "SteezeKitten"
      }
    },
    {
      "id_str": "790417941238059008",
      "text": "RT @ClimbingBlog1: Nationals Place Aaron Barrett On Outright Waivers #RockClimbing #bees https://t.co/DMRQqWUdV3",
      "hashtags": [
        "RockClimbing",
        "bees"
      ],
      "source": "<a href=\"http://myrt.dpl.local.antlab.co.uk/\" rel=\"nofollow\">MyRetweetUK</a>",
      "created_time": "2016-10-24T05:01:37.000Z",
      "retweet_count": 1,
      "user": {
        "screen_name": "BeeHouzz"
      }
    },
    {
      "id_str": "790417841690333185",
      "text": "This is how it looks at the bottom of a climb #rockclimbing #malibu @ Point Dume https://t.co/5fyqvkFGtb",
      "hashtags": [
        "rockclimbing",
        "malibu"
      ],
      "source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
      "created_time": "2016-10-24T05:01:13.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "arielkbartlett"
      }
    }
  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "max_id": "790417841690333185",
    "since_id": "790421089738424320",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790417841690333185"
  }
}

Vamos recogiendo los tweets cada vez más antiguos hasta que no queden más

Pedimos los resultados con el parámetro max_id para pedir resultados más antiguos que éste.

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790417841690333185


{
  "data": [
    {
      "id_str": "790416414544834561",
      "text": "No filter needed. #iloveyoucalifornia #rockclimbing @ Santa Monica Mountains https://t.co/orYNysMd7z",
      "hashtags": [
        "iloveyoucalifornia",
        "rockclimbing"
      ],
      "source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
      "created_time": "2016-10-24T04:55:33.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "arielkbartlett"
      }
    },
    {
      "id_str": "790414268650913792",
      "text": "Can't wait to use this👌🏻🎒🍂🎃⛺️🌄#newclimber #RockClimbing #avl #mountains #runnergirl #adventure https://t.co/fzzEZ85FPT",
      "hashtags": [
        "newclimber",
        "RockClimbing",
        "avl",
        "mountains",
        "runnergirl",
        "adventure"
      ],
      "source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
      "created_time": "2016-10-24T04:47:01.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "BreezieHannah"
      }
    }
  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "max_id": "790414268650913792",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790414268650913792"
  }
}

Seguimos pediendo información porque seguimos teniendo valores en respuesta de max_id y older_results

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790414268650913792


{
  "data": [

  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "max_id": 0,
    "older_results": null
  }
}

Esto indica que ya no tenemos resultados más antiguos.

Ahora que hemos procesado ya el primer batch, tenemos que pedir a la API los nuevos tweets que hayamos obtenido desde entonces.

Para ello, si hemos guardado los resultados de paginación de la primera búsqueda (https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320), podemos utilizarla.

Si no la hemos almacenado podemos utilizar como valor del parámetro since_id el id de tweet más grande que hayamos procesado.

A) Si todavía no ha aparecido ningún tweet, obtendremos:

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320


{
  "data": [

  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "since_id": "790421089738424320",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320"
  }
}

Esto indica que ya no tenemos resultados más antiguos.

B) Si ya han aparecido tweets:

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790421089738424320


{
  "data": [
    {
      "id_str": "790425871316357120",
      "text": "Nationals Place Aaron Barrett On Outright Waivers #RockClimbing #bees https://t.co/uUE3sRXfZ1",
      "hashtags": [
        "RockClimbing",
        "bees"
      ],
      "source": "<a href=\"https://www.socialoomph.com\" rel=\"nofollow\">SocialOomph</a>",
      "created_time": "2016-10-24T05:33:07.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "ClimbingTweets1"
      }
    },
    {
      "id_str": "790437343358443520",
      "text": "#RockClimbing Mobile Singko | Wall And Rock Climbing 101 - https://t.co/ryHLDWe689 #RT #Retweet https://t.co/btmtIX8H9Y",
      "hashtags": [
        "RockClimbing",
        "RT",
        "Retweet"
      ],
      "source": "<a href=\"http://rockclimbinghq.net\" rel=\"nofollow\">Rock Climbing HQ</a>",
      "created_time": "2016-10-24T06:18:42.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "RockClimbingHQ"
      }
    },
    {
      "id_str": "790440094121418752",
      "text": "I've been Shunky Monkey, and this has been climbing a rock. \nOver to you.\n#Monkey #rockclimbing https://t.co/uFJACfndY8",
      "hashtags": [
        "Monkey",
        "rockclimbing"
      ],
      "source": "<a href=\"http://instagram.com\" rel=\"nofollow\">Instagram</a>",
      "created_time": "2016-10-24T06:29:38.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "HalfAComic"
      }
    }
  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "max_id": "790425871316357120",
    "since_id": "790440094121418752",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790440094121418752",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790425871316357120&since_id=790421089738424320"
  }
}

La API nos da ahora los resultados ordenados de más antiguos a más modernos a partir del tweet más moderno que tenemos.

Seguimos pidiendo tweets con el valor del parámetro newer_results, o utilizando símplemente el since_id.

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790440094121418752


{
  "data": [
    {
      "id_str": "790453397988278272",
      "text": "paracord bracelet, braided bracelet, urban bracelet\n\n#rockclimbing #ropebracelet #anchorbracelet #giftformen… https://t.co/Z6JB5XxEZA",
      "hashtags": [
        "rockclimbing",
        "ropebracelet",
        "anchorbracelet",
        "giftformen"
      ],
      "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
      "created_time": "2016-10-24T07:22:30.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "BagsNadamlada"
      }
    },
    {
      "id_str": "790454289923727360",
      "text": "chalk bag climbing, rock climbing gifts\n\n#rockclimbing #bouldering #chalkbag #giftforclimber #climbing #climbers https://t.co/l7rTYTiedc",
      "hashtags": [
        "rockclimbing",
        "bouldering",
        "chalkbag",
        "giftforclimber",
        "climbing",
        "climbers"
      ],
      "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
      "created_time": "2016-10-24T07:26:03.000Z",
      "retweet_count": 0,
      "user": {
        "screen_name": "BagsNadamlada"
      }
    }
  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "max_id": "790453397988278272",
    "since_id": "790454289923727360",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790454289923727360",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=790453397988278272&since_id=790440094121418752"
  }
}

Seguimos pidiendo tweets más recientes:

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790454289923727360


{
  "data": [

  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "since_id": "790454289923727360",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=790454289923727360"
  }
}

Ya no hay más resultados, pero la api nos indica la url que hay que consultar para obtener los nuevos.

Ejemplo de información completa que aparece en un tweet

curl https://www.cool-tabs.com/api/monitors/1.json?token=xxx&limit=1&summary=false


{
  "data": [
    {
      "in_reply_to_status_id_str": null,
      "id_str": "790454289923727360",
      "in_reply_to_screen_name": null,
      "lang": "en",
      "in_reply_to_user_id": null,
      "metadata": {
        "iso_language_code": "en",
        "result_type": "recent"
      },
      "geo": null,
      "truncated": false,
      "favorite_count": 0,
      "updated_at": "2016-10-24T09:47:59.707Z",
      "coordinates": null,
      "in_reply_to_status_id": null,
      "retweet_count": 0,
      "entities": {
        "media": [
          {
            "id_str": "790454265177313280",
            "media_url": "http://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
            "media_url_https": "https://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
            "sizes": {
              "thumb": {
                "resize": "crop",
                "w": 150,
                "h": 150
              },
              "large": {
                "h": 750,
                "w": 1000,
                "resize": "fit"
              },
              "medium": {
                "h": 750,
                "w": 1000,
                "resize": "fit"
              },
              "small": {
                "resize": "fit",
                "w": 680,
                "h": 510
              }
            },
            "type": "photo",
            "display_url": "pic.twitter.com/l7rTYTiedc",
            "url": "https://t.co/l7rTYTiedc",
            "expanded_url": "https://twitter.com/BagsNadamlada/status/790454289923727360/photo/1",
            "id": 790454265177313280,
            "indices": [
              113,
              136
            ]
          }
        ],
        "user_mentions": [

        ],
        "urls": [

        ],
        "hashtags": [
          {
            "indices": [
              41,
              54
            ],
            "text": "rockclimbing"
          },
          {
            "indices": [
              55,
              66
            ],
            "text": "bouldering"
          },
          {
            "indices": [
              67,
              76
            ],
            "text": "chalkbag"
          },
          {
            "indices": [
              77,
              92
            ],
            "text": "giftforclimber"
          },
          {
            "text": "climbing",
            "indices": [
              93,
              102
            ]
          },
          {
            "indices": [
              103,
              112
            ],
            "text": "climbers"
          }
        ],
        "symbols": [

        ]
      },
      "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
      "place": null,
      "is_quote_status": false,
      "contributors": null,
      "text": "chalk bag climbing, rock climbing gifts\n\n#rockclimbing #bouldering #chalkbag #giftforclimber #climbing #climbers https://t.co/l7rTYTiedc",
      "in_reply_to_user_id_str": null,
      "extended_entities": {
        "media": [
          {
            "type": "photo",
            "display_url": "pic.twitter.com/l7rTYTiedc",
            "sizes": {
              "small": {
                "w": 680,
                "h": 510,
                "resize": "fit"
              },
              "medium": {
                "h": 750,
                "w": 1000,
                "resize": "fit"
              },
              "large": {
                "h": 750,
                "w": 1000,
                "resize": "fit"
              },
              "thumb": {
                "resize": "crop",
                "h": 150,
                "w": 150
              }
            },
            "id": 790454265177313280,
            "indices": [
              113,
              136
            ],
            "url": "https://t.co/l7rTYTiedc",
            "expanded_url": "https://twitter.com/BagsNadamlada/status/790454289923727360/photo/1",
            "id_str": "790454265177313280",
            "media_url_https": "https://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg",
            "media_url": "http://pbs.twimg.com/media/CvhB91cWEAAQyfl.jpg"
          }
        ]
      },
      "engagement": 0,
      "hashtags": [
        "rockclimbing",
        "bouldering",
        "chalkbag",
        "giftforclimber",
        "climbing",
        "climbers"
      ],
      "created_time": "2016-10-24T07:26:03.000Z",
      "possibly_sensitive": false,
      "user": {
        "_id": 726624842171174912,
        "name": "Chalk Bags Nadamlada",
        "following": false,
        "entities": {
          "url": {
            "urls": [
              {
                "display_url": "etsy.com/shop/ChalkBags…",
                "indices": [
                  0,
                  23
                ],
                "url": "https://t.co/C08BfWfycC",
                "expanded_url": "http://www.etsy.com/shop/ChalkBagsNadamlada/items"
              }
            ]
          },
          "description": {
            "urls": [

            ]
          }
        },
        "listed_count": 16,
        "favourites_count": 26,
        "url": "https://t.co/C08BfWfycC",
        "profile_sidebar_fill_color": "DDEEF6",
        "statuses_count": 215,
        "is_translator": false,
        "time_zone": "Pacific Time (US & Canada)",
        "location": "Bulgaria",
        "profile_sidebar_border_color": "C0DEED",
        "notifications": false,
        "lang": "en",
        "description": "Handmade chalk bags for rock climbing and bouldering",
        "id_str": "726624842171174912",
        "profile_text_color": "333333",
        "profile_background_image_url": null,
        "profile_background_tile": false,
        "geo_enabled": false,
        "default_profile_image": false,
        "friends_count": 26,
        "has_extended_profile": false,
        "profile_image_url": "http://pbs.twimg.com/profile_images/726656733872017408/ITO-Kkoc_normal.jpg",
        "followers_count": 31,
        "contributors_enabled": false,
        "utc_offset": -25200,
        "profile_background_image_url_https": null,
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/726656733872017408/ITO-Kkoc_normal.jpg",
        "created_at": "Sun May 01 04:10:37 +0000 2016",
        "protected": false,
        "profile_use_background_image": true,
        "default_profile": true,
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/726624842171174912/1462083368",
        "translator_type": "none",
        "profile_background_color": "F5F8FA",
        "profile_link_color": "2B7BB9",
        "verified": false,
        "ggender": "nodata",
        "follow_request_sent": false,
        "is_translation_enabled": false,
        "screen_name": "BagsNadamlada"
      },
      "id": 790454289923727360
    }
  ],
  "meta": {
    "provider": "twitter",
    "type": "hashtag",
    "search": "#rockclimbing"
  },
  "pagination": {
    "max_id": "790454289923727360",
    "since_id": "790454289923727360",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=1&summary=false&token=xxx&since_id=790454289923727360",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=1&summary=false&token=xxx&max_id=790454289923727360"
  }
}

Ejemplo de paginación Instagram

Suponemos que cuando empezáis a pedir datos a la API ya hay 5 fotos

curl https://www.cool-tabs.com/api/monitors/1.json?token=xxx&limit=3&summary=true


{
  "data": [
    {
      "created_time": "2016-10-24T15:41:37.000Z",
      "link": "https://www.instagram.com/p/BL83ku0j_2W/",
      "id": "1368212803547037078_3960632017",
      "idl": 1368212803547037078,
      "caption": {
        "text": "Monday blues? Treat yourself! 20% off our running belts with promo code: FIT1FALL for only 1 more week!! Enjoy your workout hands-free and in style with our sleek, low profile belt around your hips. .\n.\n.\n#running #hiking #walk #travel #skiing #snowboarding #cycling #explore #biking #parkour #rockclimbing #gym #fitness #workout #runningbelt #waistpack #movefit #movefitproducts #promotion #discount #fall #inspiration #style #motivation #optoutside #getoutside #lovelife #loveyourself"
      },
      "user": {
        "username": "movefit_products"
      }
    },
    {
      "created_time": "2016-10-24T15:40:58.000Z",
      "link": "https://www.instagram.com/p/BL83f94jsBT/",
      "id": "1368212476122808403_552843342",
      "idl": 1368212476122808403,
      "caption": {
        "text": "This first trip to Bishop for the season was excellent. I hope to stay focused train hard and send some cool shit.\n.\n.\n.\n.\n.\n#sonya6000 #alpha #portrait #portraiture #50mm #niftyfifty #bokeh #sony #photography #fstop #fstoppers #idyllwild #blackmountain #sky #mountains #nature #wildlife #bishop #bouldering #buttermilks #climbing #rockclimbing"
      },
      "user": {
        "username": "5.9berny"
      }
    },
    {
      "created_time": "2016-10-24T15:40:30.000Z",
      "link": "https://www.instagram.com/p/BL83cfVj7xH/",
      "id": "1368212237164985415_2025167213",
      "idl": 1368212237164985415,
      "caption": {
        "text": "Got to explore The Box near Socorro, New Mexico. I've loved every wall I've been to in NM so far and excited to find more. Climbing is a beautiful thing...\n.\n.\n.\n#climbing #climbingpicturesofinstagram #socorro #chains #newmexico #newmexicotrue #rockclimbing #nm"
      },
      "user": {
        "username": "thedesertbreeze"
      }
    }
  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "max_id": "1368212237164985415",
    "since_id": "1368212803547037078",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368212803547037078",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=1368212237164985415"
  }
}

Vamos recogiendo las fotos cada vez más antiguas hasta que no queden más

Pedimos los resultados con el parámetro max_id para pedir resultados más antiguos que éste.

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=1368212237164985415


{
  "data": [
    {
      "created_time": "2016-10-24T15:39:12.000Z",
      "link": "https://www.instagram.com/p/BL83S-KA6-n/",
      "id": "1368211583062486951_319300619",
      "idl": 1368211583062486951,
      "caption": {
        "text": "Sick shot from the homie @goodkarmadude of my flash of Smiley Right. Also managed to flash Surfboard Arête. Stoked"
      },
      "user": {
        "username": "holaesteo"
      }
    },
    {
      "created_time": "2016-10-24T15:38:55.000Z",
      "link": "https://www.instagram.com/p/BL83Q2AjWYL/",
      "id": "1368211436874851851_2255447632",
      "idl": 1368211436874851851,
      "caption": {
        "text": "All Outdoor Adventure Trips are now SOLD OUT!\nHowever, we still encourage people to sign up on Waitlists. #OutdoorAdventure #Skiing #Skydiving #RockClimbing #Horses #Snorkeling #Hiking #CSUDRW #fun #outside #happy #WhiteWater #backpacking #Adventure #horse #fitness #health #nature #adrenalin #AORE #NIRSA #climbing #winning #horsebackriding #snowboarding #surfing #paddleboarding #rafting #csulakernation #claytonstate"
      },
      "user": {
        "username": "clayton_state_sa"
      }
    }
  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "max_id": "1368211436874851851",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=1368211436874851851"
  }
}

Seguimos pediendo información porque seguimos teniendo valores en respuesta de max_id y older_results

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=1368211436874851851


{
  "data": [

  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "max_id": 0,
    "older_results": null
  }
}

Esto indica que ya no tenemos resultados más antiguos.

Ahora que hemos procesado ya el primer batch, tenemos que pedir a la API las nuevas fotos que hayamos obtenido desde entonces.

Para ello, si hemos guardado los resultados de paginación de la primera búsqueda (https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368212803547037078), podemos utilizarla.

Si no la hemos almacenado podemos utilizar como valor del parámetro since_id el id de photo más grande que hayamos procesado.

A) Si todavía no ha aparecido ninguna foto, obtendremos:

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368212803547037078


{
  "data": [

  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "since_id": "1368212803547037078",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368212803547037078"
  }
}

Esto indica que ya no tenemos resultados más antiguos.

B) Si ya han aparecido fotos:

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368212803547037078


{
  "data": [
    {
      "created_time": "2016-10-24T15:43:59.000Z",
      "link": "https://www.instagram.com/p/BL832DyDusv/",
      "id": "1368213994284706607_1248293389",
      "idl": 1368213994284706607,
      "caption": {
        "text": "Building anchors #rockclimbing #pilotmountain #ncstateparks #twoonthetrail"
      },
      "user": {
        "username": "twoonthetrail"
      }
    },
    {
      "created_time": "2016-10-24T15:44:17.000Z",
      "link": "https://www.instagram.com/p/BL834ObBTG4/",
      "id": "1368214143148306872_245155377",
      "idl": 1368214143148306872,
      "caption": {
        "text": "Just casually sitting at the #top of the #rock #climb #climbing #rockclimbing northwales slate quarry again"
      },
      "user": {
        "username": "82dandanh"
      }
    },
    {
      "created_time": "2016-10-24T15:44:30.000Z",
      "link": "https://www.instagram.com/p/BL835wigJmA/",
      "id": "1368214248500533632_178418822",
      "idl": 1368214248500533632,
      "caption": {
        "text": "Blending in fall colors"
      },
      "user": {
        "username": "maine08"
      }
    }
  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "max_id": "1368213994284706607",
    "since_id": "1368214248500533632",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368214248500533632",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=1368213994284706607&since_id=1368212803547037078"
  }
}

La API nos da ahora los resultados ordenados de más antiguos a más modernos a partir del photo más moderno que tenemos.

Seguimos pidiendo fotos con el valor del parámetro newer_results, o utilizando símplemente el since_id.

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368214248500533632


{
  "data": [
    {
      "created_time": "2016-10-24T15:44:43.000Z",
      "link": "https://www.instagram.com/p/BL837ZcAPEe/",
      "id": "1368214361134395678_471006445",
      "idl": 1368214361134395678,
      "caption": {
        "text": "Ambassador @danielaebler on One Robe, One Bowl 5.12c  in Banff, Canada.  Her trip has given us some serious wanderlust! Read her blog, sharing her favourite crags on our website 3rdrockclothing.com ‘Daniela’s Trip to Beautiful Canada’\n.\n.\n.\nPictured: organic TITAN ORBIT leggings & recycled ECLIPSE vest\n.\n.\n.\nPic: @sonnietrotter\n#climbing_pictures_of_instagram #climbinglife #climbingrocks #climbing_is_my_passion #activewear #bouldering #sportclimbing #rockclimbing #sustainablefashion #organicfashion #organiccotton #outdoorclothing #c_l_i_m_b #ratherbeclimbing #recycledclothing #recycledfashion #ethical #belongorgetstrong #climbing #indoorclimbing rockclimbing #womenswear #wanderlust #canada #canmore #banff"
      },
      "user": {
        "username": "3rdrocking"
      }
    },
    {
      "created_time": "2016-10-24T15:44:52.000Z",
      "link": "https://www.instagram.com/p/BL838cJjhQo/",
      "id": "1368214432765580328_2918160270",
      "idl": 1368214432765580328,
      "caption": {
        "text": "Sorry i’m busy climbing.  Pc:@timkemple\n#explore #rei1440project #clymblife #wearealladventurers #exploreeverything #theglobewanderer #goneoutdoors #adventureinspired #greatnorthcollective #climbing #rockclimbing #tryhard #liveclimbrepeat #goforit #loveyouraltitude #touchthesky #outdoors #mountaineering #mountain #training #bouldering #climb #adventure #travel #fitness #climbinglife #madeinusa #arcirisglasses #woodsunglasses"
      },
      "user": {
        "username": "ai.climb"
      }
    }
  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "max_id": "1368214361134395678",
    "since_id": "1368214432765580328",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368214432765580328",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&max_id=1368214361134395678&since_id=1368214248500533632"
  }
}

Seguimos pidiendo fotos más recientes:

curl https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368214432765580328


{
  "data": [

  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "since_id": "1368214432765580328",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=3&summary=true&token=xxx&since_id=1368214432765580328"
  }
}

Ya no hay más resultados, pero la api nos indica la url que hay que consultar para obtener los nuevos.

Ejemplo de información completa que aparece en una foto/vídeo de instagram

curl https://www.cool-tabs.com/api/monitors/1.json?token=xxx&limit=1&summary=false


{
  "data": [
    {
      "users_in_photo": [

      ],
      "caption": {
        "text": "Sorry i’m busy climbing.  Pc:@timkemple\n#explore #rei1440project #clymblife #wearealladventurers #exploreeverything #theglobewanderer #goneoutdoors #adventureinspired #greatnorthcollective #climbing #rockclimbing #tryhard #liveclimbrepeat #goforit #loveyouraltitude #touchthesky #outdoors #mountaineering #mountain #training #bouldering #climb #adventure #travel #fitness #climbinglife #madeinusa #arcirisglasses #woodsunglasses",
        "from": {
          "full_name": "Arc-Iris Climb",
          "profile_picture": "http://scontent.cdninstagram.com/t51.2885-19/14350957_1806881182892511_8655379186237571072_a.jpg",
          "username": "ai.climb",
          "id": "2918160270"
        },
        "id": "17843621305140328",
        "created_time": "1477323892"
      },
      "type": "image",
      "likes": {
        "count": 21
      },
      "created_time": "2016-10-24T15:44:52.000Z",
      "filter": "Normal",
      "location": null,
      "user_has_liked": false,
      "comments": {
        "count": 0
      },
      "link": "https://www.instagram.com/p/BL838cJjhQo/",
      "idl": 1368214432765580328,
      "attribution": null,
      "user": {
        "full_name": "Arc-Iris Climb",
        "profile_picture": "http://scontent.cdninstagram.com/t51.2885-19/14350957_1806881182892511_8655379186237571072_a.jpg",
        "username": "ai.climb",
        "id": "2918160270"
      },
      "images": {
        "low_resolution": {
          "url": "https://scontent.cdninstagram.com/t51.2885-15/e35/p320x320/14583298_332164847145821_1309729592352702464_n.jpg?ig_cache_key=MTM2ODIxNDQzMjc2NTU4MDMyOA%3D%3D.2",
          "height": 399,
          "width": 320
        },
        "standard_resolution": {
          "url": "https://scontent.cdninstagram.com/t51.2885-15/sh0.08/e35/p640x640/14583298_332164847145821_1309729592352702464_n.jpg?ig_cache_key=MTM2ODIxNDQzMjc2NTU4MDMyOA%3D%3D.2",
          "width": 640,
          "height": 799
        },
        "thumbnail": {
          "width": 150,
          "height": 150,
          "url": "https://scontent.cdninstagram.com/t51.2885-15/s150x150/e35/c0.134.1080.1080/14583298_332164847145821_1309729592352702464_n.jpg?ig_cache_key=MTM2ODIxNDQzMjc2NTU4MDMyOA%3D%3D.2.c"
        }
      },
      "tags": [
        "greatnorthcollective",
        "rockclimbing",
        "arcirisglasses",
        "climbinglife",
        "rei1440project",
        "touchthesky",
        "outdoors",
        "training",
        "madeinusa",
        "tryhard",
        "fitness",
        "explore",
        "liveclimbrepeat",
        "adventure",
        "goforit",
        "climbing",
        "loveyouraltitude",
        "mountain",
        "goneoutdoors",
        "bouldering",
        "clymblife",
        "exploreeverything",
        "travel",
        "wearealladventurers",
        "theglobewanderer",
        "woodsunglasses",
        "adventureinspired",
        "mountaineering",
        "climb"
      ],
      "id": "1368214432765580328_2918160270"
    }
  ],
  "meta": {
    "provider": "instagram",
    "type": "hashtag",
    "search": "rockclimbing"
  },
  "pagination": {
    "max_id": "1368214432765580328",
    "since_id": "1368214432765580328",
    "newer_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=1&summary=false&token=xxx&since_id=1368214432765580328",
    "older_results": "https://www.cool-tabs.com/api/monitors/1.json?limit=1&summary=false&token=xxx&max_id=1368214432765580328"
  }
}