---
agentTools:
  projectIndex: https://docs.gifs.com/llms.txt
---

# /media/import

We support importing the following file mime types: `image/gif`, `video/mp4`, `video/webm` and you can also link directly to a `giphy`, `imgur`, `gfycat`, `streamable`, `instagram`, `twitter`, `facebook`, or `vine` web page and we'll automagically find the best quality file to import.

Use your Authentication Key for added benefits. Read [Authentication Key](http://docs.gifs.com/docs/authentication-key) for full benefits.

Attribution object schema is:

| Parameter | Type   | Required? | Description                                       |
| --------- | ------ | --------- | ------------------------------------------------- |
| site      | string | required  | twitter, reddit, instagram, vine, or a custom URL |
| user      | string | optional  | The username for social media sites               |
| url       | string | optional  | The url if site != social media                   |

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "API Settings",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.gifs.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "name": "gifs-api-key",
        "in": "header",
        "x-default": "gifs56d63999f0f34"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/media/import": {
      "post": {
        "summary": "/media/import",
        "description": "We support importing the following file mime types: `image/gif`, `video/mp4`, `video/webm` and you can also link directly to a `giphy`, `imgur`, `gfycat`, `streamable`, `instagram`, `twitter`, `facebook`, or `vine` web page and we'll automagically find the best quality file to import.\n\nUse your Authentication Key for added benefits. Read [Authentication Key](http://docs.gifs.com/docs/authentication-key) for full benefits.",
        "operationId": "mediaimport",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "source"
                ],
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "The source URL of the media to add"
                  },
                  "title": {
                    "type": "string",
                    "description": "The title of the media"
                  },
                  "tags": {
                    "type": "array",
                    "description": "The tags relating the the media",
                    "items": {
                      "type": "string"
                    }
                  },
                  "nsfw": {
                    "type": "boolean",
                    "description": "If the media is not safe for work"
                  },
                  "attribution": {
                    "type": "object",
                    "description": "Any attribution you want displayed",
                    "properties": {}
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"success\": {\n        \"page\": \"https://gifs.com/gif/YEV5Jp\",\n        \"files\": {\n            \"gif\": \"https://j.gifs.com/YEV5Jp.gif\",\n            \"jpg\": \"https://j.gifs.com/YEV5Jp.jpg\",\n            \"mp4\": \"https://j.gifs.com/YEV5Jp.mp4\",\n            \"webm\": \"https://j.gifs.com/YEV5Jp.webm\"\n        },\n        \"oembed\": \"https://gifs.com/oembed/YEV5Jp\",\n        \"embed\": \"<iframe src='https://gifs.com/embed/YEV5Jp' frameborder='0' scrolling='no' width='720' height='720' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' ></iframe>\",\n        \"meta\": {\n            \"duration\": \"6.5s\",\n            \"height\": \"720\",\n            \"width\": \"720\"\n        }\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "string",
                          "example": "https://gifs.com/gif/YEV5Jp"
                        },
                        "files": {
                          "type": "object",
                          "properties": {
                            "gif": {
                              "type": "string",
                              "example": "https://j.gifs.com/YEV5Jp.gif"
                            },
                            "jpg": {
                              "type": "string",
                              "example": "https://j.gifs.com/YEV5Jp.jpg"
                            },
                            "mp4": {
                              "type": "string",
                              "example": "https://j.gifs.com/YEV5Jp.mp4"
                            },
                            "webm": {
                              "type": "string",
                              "example": "https://j.gifs.com/YEV5Jp.webm"
                            }
                          }
                        },
                        "oembed": {
                          "type": "string",
                          "example": "https://gifs.com/oembed/YEV5Jp"
                        },
                        "embed": {
                          "type": "string",
                          "example": "<iframe src='https://gifs.com/embed/YEV5Jp' frameborder='0' scrolling='no' width='720' height='720' style='-webkit-backface-visibility: hidden;-webkit-transform: scale(1);' ></iframe>"
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "duration": {
                              "type": "string",
                              "example": "6.5s"
                            },
                            "height": {
                              "type": "string",
                              "example": "720"
                            },
                            "width": {
                              "type": "string",
                              "example": "720"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"errors\": {\n        \"message\": \"We've encountered an unexpected issue, please try again.\"\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "We've encountered an unexpected issue, please try again."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl -X POST -H \"Gifs-API-Key: gifs56d63999f0f34\" -H \"Content-Type: application/json\" -d '{\n \"source\": \"https://vine.co/v/ibAU6OH2I0K\",\n \"title\": \"2015 Craziness\",\n \"tags\": [\"crazy\", \"hand drawn\", \"2015\", \"art\"],\n \"attribution\": {\n   \"site\": \"vine\",\n   \"user\": \"AliciaHerber\"\n }\n}' \"https://api.gifs.com/media/import\""
            },
            {
              "language": "php",
              "code": "<?php\n\n$request = new HttpRequest();\n$request->setUrl('https://api.gifs.com/media/import');\n$request->setMethod(HTTP_METH_POST);\n\n$request->setHeaders(array(\n  'Gifs-API-Key' => 'gifs56d63999f0f34'\n  'Content-Type' => 'application/json'\n));\n\n$request->setBody('{\n \"source\": \"https://vine.co/v/ibAU6OH2I0K\",\n \"title\": \"2015 Craziness\",\n \"tags\": [\"crazy\", \"hand drawn\", \"2015\", \"art\"],\n \"attribution\": {\n   \"site\": \"vine.co\",\n   \"user\": \"AliciaHerber\"\n }\n}');\n\ntry {\n  $response = $request->send();\n\n  echo $response->getBody();\n} catch (HttpException $ex) {\n  echo $ex;\n}"
            },
            {
              "language": "java",
              "code": "HttpResponse<String> response = Unirest.post(\"https://api.gifs.com/media/import\")\n  .header(\"Gifs-API-Key\", \"gifs56d63999f0f34\")\n  .header(\"Content-Type\", \"application/json\")\n  .body(\"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\")\n  .asString();"
            },
            {
              "language": "go",
              "code": "url := \"https://api.gifs.com/media/import\"\n\npayload := strings.NewReader(\"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\")\n\nreq, _ := http.NewRequest(\"POST\", url, payload)\nreq.Header.Add(\"Gifs-API-Key\", \"gifs56d63999f0f34\")\nreq.Header.Add(\"Content-Type\", \"application/json\")\n\nres, _ := http.DefaultClient.Do(req)\n\ndefer res.Body.Close()\nbody, _ := ioutil.ReadAll(res.Body)\n\nfmt.Println(res)\nfmt.Println(string(body))"
            },
            {
              "language": "javascript",
              "code": "var http = require(\"https\");\n\nvar options = {\n  \"method\": \"POST\",\n  \"hostname\": \"api.gifs.com\",\n  \"port\": null,\n  \"path\": \"/media/import\",\n  \"headers\": {\n    \"Gifs-API-Key\": \"gifs56d63999f0f34\",\n    \"Content-Type\": \"application/json\"\n  }\n};\n\nvar req = http.request(options, function (res) {\n  var chunks = [];\n\n  res.on(\"data\", function (chunk) {\n    chunks.push(chunk);\n  });\n\n  res.on(\"end\", function () {\n    var body = Buffer.concat(chunks);\n    console.log(body.toString());\n  });\n});\n\nreq.write(JSON.stringify({ source: 'https://vine.co/v/ibAU6OH2I0K',\n  title: '2015 Craziness',\n  tags: [ 'cat', 'hand drawn', 'cat flip', 'art' ],\n  attribution: { site: 'vine.co', user: 'AliciaHerber' } }));\nreq.end();",
              "name": "Nodejs"
            },
            {
              "language": "javascript",
              "code": "var settings = {\n  \"async\": true,\n  \"crossDomain\": true,\n  \"url\": \"https://api.gifs.com/media/import\",\n  \"method\": \"POST\",\n  \"headers\": {\n    \"Gifs-API-Key\": \"gifs56d63999f0f34\",\n    \"Content-Type\": \"application/json\"\n  },\n  \"processData\": false,\n  \"data\": \"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\"\n}\n\n$.ajax(settings).done(function (response) {\n  console.log(response);\n});",
              "name": "jQuery"
            },
            {
              "language": "python",
              "code": "import http.client\n\nconn = http.client.HTTPSConnection(\"api.gifs.com\")\n\npayload = \"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\"\n\nheaders = { 'Gifs-API-Key': \"gifs56d63999f0f34\", 'Content-Type': \"application/json\" }\n\nconn.request(\"POST\", \"/media/import\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
            },
            {
              "language": "ruby",
              "code": "require 'uri'\nrequire 'net/http'\n\nurl = URI(\"https://api.gifs.com/media/import\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Gifs-API-Key\"] = 'gifs56d63999f0f34'\nrequest[\"Content-Type\"] = 'application/json'\nrequest.body = \"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\"\n\nresponse = http.request(request)\nputs response.read_body"
            },
            {
              "language": "swift",
              "code": "import Foundation\n\nlet parameters = [\n  \"source\": \"https://vine.co/v/ibAU6OH2I0K\",\n  \"title\": \"2015 Craziness\",\n  \"tags\": [\"crazy\", \"hand drawn\", \"2015\", \"art\"],\n  \"attribution\": [\n    \"site\": \"vine.co\",\n    \"user\": \"AliciaHerber\"\n  ]\n]\n\nlet postData = NSJSONSerialization.dataWithJSONObject(parameters, options: nil, error: nil)\n\nvar request = NSMutableURLRequest(URL: NSURL(string: \"https://api.gifs.com/media/import\")!,\n                                        cachePolicy: .UseProtocolCachePolicy,\n                                    timeoutInterval: 10.0)\nrequest.HTTPMethod = \"POST\"\nrequest.allHTTPHeaderFields = [ \"Gifs-API-Key\": \"gifs56d63999f0f34\", \"Content-Type\": \"application/json\" ]\nrequest.HTTPBody = postData\n\nlet session = NSURLSession.sharedSession()\nlet dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in\n  if (error != nil) {\n    println(error)\n  } else {\n    let httpResponse = response as? NSHTTPURLResponse\n    println(httpResponse)\n  }\n})\n\ndataTask.resume()"
            },
            {
              "language": "objectivec",
              "code": "#import <Foundation/Foundation.h>\n\nNSDictionary *headers = @{ @\"Gifs-API-Key\": @\"gifs56d63999f0f34\",\n                        @\"Content-Type\": @\"application/json\" };\n\nNSDictionary *parameters = @{ @\"source\": @\"https://vine.co/v/ibAU6OH2I0K\",\n                              @\"title\": @\"2015 Craziness\",\n                              @\"tags\": @[ @\"crazy\", @\"hand drawn\", @\"2015\", @\"art\" ],\n                              @\"attribution\": @{ @\"site\": @\"vine.co\", @\"user\": @\"AliciaHerber\" } };\n\nNSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];\n\nNSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@\"https://api.gifs.com/media/import\"]\n                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy\n                                                   timeoutInterval:10.0];\n[request setHTTPMethod:@\"POST\"];\n[request setAllHTTPHeaderFields:headers];\n[request setHTTPBody:postData];\n\nNSURLSession *session = [NSURLSession sharedSession];\nNSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request\n                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {\n                                                if (error) {\n                                                    NSLog(@\"%@\", error);\n                                                } else {\n                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;\n                                                    NSLog(@\"%@\", httpResponse);\n                                                }\n                                            }];\n[dataTask resume];"
            },
            {
              "language": "c",
              "code": "CURL *hnd = curl_easy_init();\n\ncurl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, \"POST\");\ncurl_easy_setopt(hnd, CURLOPT_URL, \"https://api.gifs.com/media/import\");\n\nstruct curl_slist *headers = NULL;\nheaders = curl_slist_append(headers, \"Gifs-API-Key: gifs56d63999f0f34\");\nheaders = curl_slist_append(headers, \"Content-Type: application/json\");\ncurl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);\n\ncurl_easy_setopt(hnd, CURLOPT_POSTFIELDS, \"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\");\n\nCURLcode ret = curl_easy_perform(hnd);"
            },
            {
              "language": "csharp",
              "code": "var client = new RestClient(\"https://api.gifs.com/media/import\");\nvar request = new RestRequest(Method.POST);\nrequest.AddHeader(\"Content-Type\", \"Gifs-API-Key: gifs56d63999f0f34\");\nrequest.AddHeader(\"Content-Type\", \"application/json\");\nrequest.AddParameter(\"application/json\", \"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\", ParameterType.RequestBody);\nIRestResponse response = client.Execute(request);"
            },
            {
              "language": "shell",
              "code": "open Cohttp_lwt_unix\nopen Cohttp\nopen Lwt\n\nlet uri = Uri.of_string \"https://api.gifs.com/media/import\" in\nlet headers = Header.init ()\n  |> fun h -> Header.add h \"Gifs-API-Key\" \"gifs56d63999f0f34\"\n  |> fun h -> Header.add h \"Content-Type\" \"application/json\"\nin\nlet body = Cohttp_lwt_body.of_string \"{\\n \\\"source\\\": \\\"https://vine.co/v/ibAU6OH2I0K\\\",\\n \\\"title\\\": \\\"2015 Craziness\\\",\\n \\\"tags\\\": [\\\"crazy\\\", \\\"hand drawn\\\", \\\"2015\\\", \\\"art\\\"],\\n \\\"attribution\\\": {\\n   \\\"site\\\": \\\"vine.co\\\",\\n   \\\"user\\\": \\\"AliciaHerber\\\"\\n }\\n}\" in\n\nClient.call ~headers ~body `POST uri\n>>= fun (res, body_stream) ->\n  (* Do stuff with the result *)",
              "name": "OCaml"
            }
          ],
          "samples-languages": [
            "curl",
            "php",
            "java",
            "go",
            "javascript",
            "python",
            "ruby",
            "swift",
            "objectivec",
            "c",
            "csharp",
            "shell"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "63053f479807941f67a92c32:56cf9a978acacb1300814918"
}
```