= Instagram API


[[_overview]]
== Overview
The first version of the Instagram API is an exciting step forward towards
making it easier for users to have open access to their data. We created it
so that you can surface the amazing content Instagram users share every
second, in fun and innovative ways.

Build something great!

Once you've
http://instagram.com/developer/register/[registered your client] it's easy
to start requesting data from Instagram.

All endpoints are only accessible via https and are located at
`api.instagram.com`. For instance: you can grab the most popular photos at
the moment by accessing the following URL with your client ID
(replace CLIENT-ID with your own):

----
  https://api.instagram.com/v1/media/popular?client_id=CLIENT-ID
----

You're best off using an access_token for the authenticated user for each
endpoint, though many endpoints don't require it.
In some cases an access_token will give you more access to information, and
in all cases, it means that you are operating under a per-access_token limit
vs. the same limit for your single client_id.

== Limits

Be nice. If you're sending too many requests too quickly, we'll send back a
`503` error code (server unavailable).
You are limited to 5000 requests per hour per `access_token` or `client_id`
overall. Practically, this means you should (when possible) authenticate
users so that limits are well outside the reach of a given user.

== Deleting Objects

We do our best to have all our URLs be
http://en.wikipedia.org/wiki/Representational_state_transfer[RESTful].
Every endpoint (URL) may support one of four different http verbs. GET
requests fetch information about an object, POST requests create objects,
PUT requests update objects, and finally DELETE requests will delete
objects.

Since many old browsers don't support PUT or DELETE, we've made it easy to
fake PUTs and DELETEs. All you have to do is do a POST with _method=PUT or
_method=DELETE as a parameter and we will treat it as if you used PUT or
DELETE respectively.

== Structure

=== The Envelope

Every response is contained by an envelope. That is, each response has a
predictable set of keys with which you can expect to interact:

[source,json]
----
{
    "meta": {
        "code": 200
    },
    "data": {
        ...
    },
    "pagination": {
        "next_url": "...",
        "next_max_id": "13872296"
    }
}
----

==== META

The meta key is used to communicate extra information about the response to
the developer. If all goes well, you'll only ever see a code key with value
200. However, sometimes things go wrong, and in that case you might see a
response like:

[source,json]
----
{
    "meta": {
        "error_type": "OAuthException",
        "code": 400,
        "error_message": "..."
    }
}
----

==== DATA

The data key is the meat of the response. It may be a list or dictionary,
but either way this is where you'll find the data you requested.

==== PAGINATION

Sometimes you just can't get enough. For this reason, we've provided a
convenient way to access more data in any request for sequential data.
Simply call the url in the next_url parameter and we'll respond with the
next set of data.

[source,json]
----
{
    ...
    "pagination": {
        "next_url": "https://api.instagram.com/v1/tags/puppy/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&max_id=13872296",
        "next_max_id": "13872296"
    }
}
----

On views where pagination is present, we also support the "count" parameter.
Simply set this to the number of items you'd like to receive. Note that the
default values should be fine for most applications - but if you decide to
increase this number there is a maximum value defined on each endpoint.

=== JSONP

If you're writing an AJAX application, and you'd like to wrap our response
with a callback, all you have to do is specify a callback parameter with
any API call:

----
https://api.instagram.com/v1/tags/coffee/media/recent?access_token=fb2e77d.47a0479900504cb3ab4a1f626d174d2d&callback=callbackFunction
----

Would respond with:

[source,js]
----
callbackFunction({
    ...
});
----


=== Version information
[%hardbreaks]
__Version__ : v1


=== License information
[%hardbreaks]
__Terms of service__ : http://instagram.com/about/legal/terms/api


=== URI scheme
[%hardbreaks]
__Host__ : api.instagram.com
__BasePath__ : /v1
__Schemes__ : HTTPS


=== Tags

* Users
* Relationships : Relationships are expressed using the following terms:

**outgoing_status**: Your relationship to the user. Can be "follows",
  "requested", "none".
**incoming_status**: A user's relationship to you. Can be "followed_by",
  "requested_by", "blocked_by_you", "none".

* Media : At this time, uploading via the API is not possible. We made a conscious
choice not to add this for the following reasons:

* Instagram is about your life on the go – we hope to encourage photos
  from within the app.
* We want to fight spam & low quality photos. Once we allow uploading
  from other sources, it's harder to control what comes into the Instagram
  ecosystem. All this being said, we're working on ways to ensure users
  have a consistent and high-quality experience on our platform.

* Commnts
* Likes
* Tags
* Location
* Subscribtions


=== Consumes

* `application/json`


=== Produces

* `application/json`



