Skip to content
This repository has been archived by the owner on Feb 27, 2021. It is now read-only.

Latest commit

 

History

History
46 lines (42 loc) · 1.36 KB

create_snippet.md

File metadata and controls

46 lines (42 loc) · 1.36 KB

Create snippet

Create anonymous snippet
curl --request POST \
     --header 'Content-type: application/json' \
     --data '{"language": "python", "title": "test", "public": true, "files": [{"name": "main.py", "content": "print(42)"}]}' \
     --url 'https://snippets.glot.io/snippets'
Create snippet (requires api token)
curl --request POST \
     --header 'Authorization: Token 0123456-789a-bcde-f012-3456789abcde' \
     --header 'Content-type: application/json' \
     --data '{"language": "python", "title": "test", "public": false, "files": [{"name": "main.py", "content": "print(42)"}]}' \
     --url 'https://snippets.glot.io/snippets'

Example request data

{
  "language": "python",
  "title": "test",
  "public": false,
  "files": [
    {
      "name": "main.py",
      "content": "print(42)"
    }
  ]
}

Example response data

{
  "id": "e374w14ai4",
  "url": "https://snippets.glot.io/snippets/e374w14ai4",
  "created": "2015-05-05T21:38:36Z",
  "modified": "2015-05-05T21:38:36Z",
  "files_hash": "f55a5b888fa89b60b8eb5e71cc0d18aeb50e8c81",
  "language": "python",
  "title": "test",
  "public": true,
  "owner": "anonymous",
  "files": [
    {
      "name": "main.py",
      "content": "print(42)"
    }
  ]
}