2Post Tech

Last updated: March 14, 2017

An HTTP API for turning GETs into POSTs

Version 1 of the API. Stable since launch; the docs are the whole site.

The API is for clients that can only fetch an address. The request you want sent is written into a link; fetching the link sends it, and what the other side answers comes back to you.

The API is free. There is no account to open and no key to send.

Everything on this page is served from one host:

2post.tech

Requests go out to any public http or https address.

Making a request

The full description, as plain text. A program can read it as easily as a person; the example on the right is the one it uses.

2Post Tech: An HTTP API for turning GETs into POSTs

Put the address and the body in a link and fetch it. This POSTs
{"hello":"from-a-link"} to https://httpbun.com/anything, which answers
with a description of the request it got, and gives you that answer,
status code and headers included:

    https://www.2post.tech/api/forward?url=https://httpbun.com/anything&body=%7B%22hello%22%3A%22from-a-link%22%7D

With curl, which does the encoding for you:

    curl -G https://www.2post.tech/api/forward --data-urlencode 'url=https://httpbun.com/anything' --data-urlencode 'body={"hello":"from-a-link"}'

Something other than a POST, or with headers of your own:

    https://www.2post.tech/api/forward?url=https://httpbun.com/anything/7&method=DELETE
    https://www.2post.tech/api/forward?url=https://httpbun.com/anything/7&method=PUT&body=name%3Dnew&headers=%7B%22Authorization%22%3A%22Bearer%20abc%22%7D

headers is a JSON object, here {"Authorization":"Bearer abc"}. A body
that is JSON goes out as application/json, a=1&b=2 as a form, anything
else as text; content_type=... says otherwise. Add response=json to
get the answer wrapped in an object with "status", "headers" and
"body". http and https only. Redirects are followed. No key, no
account.

The example request:

curl -G https://www.2post.tech/api/forward --data-urlencode 'url=https://httpbun.com/anything' --data-urlencode 'body={"hello":"from-a-link"}'
https://www.2post.tech/api/forward?url=https://httpbun.com/anything&body=%7B%22hello%22%3A%22from-a-link%22%7D

It is sent to a public test address, which answers with what it received.

Try it

Fill in a request and send it from here. The form makes the same kind of link as the one described above, so the address bar afterwards holds a link you can keep.




A link of the kind the form makes:

Link
https://www.2post.tech/api/forward?url=https://httpbun.com/anything&body=%7B%22hello%22%3A%22from-a-link%22%7D

Fetch it with anything that can open an address.

Methods and headers

A link can send any of these methods, with a body, and with headers of your own.

MethodUsually means
POSTHand something new to the other side
PUTReplace what is there
PATCHChange part of what is there
DELETERemove it

How the method, the body and each header are written into the link is set out under Making a request.

Custom headers travel with the request to the other side.

Responses

What you get back is the other side's answer to the request that was sent for you. For what can go wrong, see Errors.

The answer returned is the other side's answer.