Use our API to connect your Application to img.ly

The API Endpoint is, depending on your desired format http://img.ly/api/2/upload.json (explicit JSON)
http://img.ly/api/2/upload.xml (explicit XML)
http://img.ly/api/2/upload (inspects Accepts-Header)

HTTP Method

POST

Responses

The request will return 200 if everything went right. It will return a 401 Unauthorized if the OAuth header was not present or could not be verified with Twitter. It will return a 400 Bad Request if one of the required parameters is missing.

Headers

X-Verify-Credentials-Authorization (Required)

Header Example:

OAuth realm="http://api.twitter.com/",
oauth_consumer_key="abcdefghijklmnopqrst",
oauth_signature_method="HMAC-SHA1",
oauth_token="123456-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP",
oauth_timestamp="1234567890",
oauth_nonce="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO",
oauth_version="1.0",
oauth_signature="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO"

X-Auth-Service-Provider (Required)

Header Example:

X-Auth-Service-Provider: https://api.twitter.com/1.1/account/verify_credentials.json

Parameters

  • message: The tweet that belongs to the image.
  • media (Required): The file upload data.

Responses

If you receive a HTTP 200 OK header, you can assume the image was successfully uploaded.

Sample XML Reponse:

<?xml version="1.0" encoding="UTF-8"?>
<image>
    <id>3de</id>
    <text>some text</text>
    <url>http://img.ly/3de</url>
    <width>300</width>
    <height>200</height>
    <size>8211</size>
    <type>png</type>
    <timestamp>Wed, 2 June 2010 11:11:11 +0000</timestamp>
    <user>
        <id>123456</id>
        <screen_name>imglyuser</screen_name>
    </user>
</image>

Sample JSON Reponse

{
    "id" : "3de",
    "text" : "test",
    "url" : "http:\/\/img.ly\/3de",
    "width" : 300,
    "height" : 200,
    "size" : 8211,
    "type" : "png",
    "timestamp" : "Wed, 2 June 2010 11:11:11 +0000",
    "user" : {
        "id" : 123456,
        "screen_name" : "imglytest"
    }
}

Example CURL Command

curl -v -H 'X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json' \
     -H 'X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/", oauth_consumer_key="abcdefghij", oauth_signature_method="HMAC-SHA1", oauth_token="123456-abcdefg", oauth_timestamp="1234567890", oauth_nonce="abcdef", oauth_version="1.0", oauth_signature="abcdefgh"'
     -F "media=@/path/to/image" http://img.ly/api/2/upload.json

Viewing images

To display an image, use a URL in this format:

http://img.ly/show/[mini|thumb|medium|large|full]/<image-id>

Example for a thumb URL:

http://img.ly/show/thumb/3de

These URLs will HTTP-redirect to the actual location of the image-file. Never use those locations directly, always use the img.ly-url as described above. The actual locations of image files can change at any time!