API Documentation

Hey :slightly_smiling_face:

Wondering about the API documentation for this one, as I’d like to get a Shortcut, or Drafts action, going.

Asking for a friend. And I mean it :rofl:

4 Likes

I haven’t added anything to the official documentation because I was just getting ready to completely overhaul that (more info on that soon). But I don’t want to keep anyone waiting, so here’s a quick explanation of the upload endpoint (which is what I imagine most people care about):

Upload a picture

POST https://api.omg.lol/address/:address/pics/upload
Authorization: Bearer Token (API Key)
POST payload can consist of:

  1. Raw binary image data
  2. A data: URI
  3. A JSON object with a pic key containing base64-encoded binary image data

You’ll receive a response like this:

{
    "request": {
        "status_code": 200,
        "success": true
    },
    "response": {
        "message": "Your picture has been uploaded.",
        "id": "64120bb50a8c7",
        "size": 9445,
        "mime": "image/png",
        "url": "https://cdn.some.pics/adam/64120bb50a8c7.png"
    }
}

Unfortunately I don’t yet have a way to set a description in the same call (I’ll set it up soon, though). Until then, you can make a second call to set the description like this:

POST https://api.omg.lol/address/:address/pics/:id
(:id is the same ID returned value above)
{"description": "Your picture description here"}

Hope this helps!

4 Likes

Yay! Thanks, it helps, a lot. Now let’s see if I can get it to work :rofl::rofl:

2 Likes

Is there an API for accessing all photos posted to some.pics yet?

1 Like

There wasn’t, but there is now!

GET https://api.omg.lol/pics

Let me know if you have any feedback on the response!

1 Like

Thanks! How about a list instead of dictionary?

1 Like

Sorry, I’m forever messing that up. Should be better now!

No worries! Thanks, looks great!

1 Like

I’m getting a 413 error for payloads greater than 3MB on the endpoint. I’ve tested a 5.33MB and a 3.8MB in all three payload types (raw, uri, and json). Smaller files <=3MB seem to work fine. Uploading larger files via web interface works without issue.

I was expecting files <=8MB to be accepted like the web interface. Am I doing something wrong or is there a restriction I missed?

1 Like

I don’t think you’re doing anything wrong — I’m going to dig into some logs and try to see what’s going on with this. Stay tuned!

1 Like