Carbon API

Version 1.3.0

Introduction

Carbon is a freely available HTTP Request & Response Service. It is an ongoing project designed by Corey Edwards as an experiment in developing a public-facing API in PHP.

Examples

Now

Endpoint: /now

Returns the current time, in a variety of formats.

$ curl https://carbon-api.tk/now
{
    "request_time": 1507635156.020285,
    "now": {
        "epoch": 1507635156.022229,
        "slang_date": "today",
        "slang_time": "now",
        "iso8601": "2017-10-10T11:32:36+00:00",
        "rfc2822": "Tue, 10 Oct 2017 11:32:36 +0000",
        "rfc3339": "2017-10-10T11:32:36+00:00"
    }
}
            

IP Address

Endpoint: /ip

Returns the IP address of the client.

$ curl https://carbon-api.tk/ip
{
  "origin": "127.0.0.1"
}
            

User agent

Endpoint: /user-agent

Returns the user-agent of the client.

$ curl https://carbon-api.tk/user-agent
{
  "user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0"
}
            

Headers

Endpoint: /headers

Returns all HTTP request headers from the current request.

$ curl https://carbon-api.tk/headers
{
    "headers": {
        "Host": "carbon-api.tk",
        "User-Agent": "Mozilla/5.0 (X11; Linux i586; rv:31.0) Gecko/20100101 Firefox/31.0",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Language": "en-US,en;q=0.5",
        "Accept-Encoding": "gzip, deflate",
        "Cookie": "_ga=GA1.1.1082408841.1496132797",
        "DNT": "1",
        "Connection": "keep-alive",
        "Upgrade-Insecure-Requests": "1",
        "Cache-Control": "max-age=0"
    }
}
            

Download

Endpoint: /download

Generates n megabytes of data where ?size=n. The data file consists of alternating 1's and 0's.

$ curl https://carbon-api.tk/download?size=100M
HTTP/1.1 200 OK
Host: carbon-api.tk
Date: Tue, 10 Oct 2017 19:46:17 +0000
Connection: close
server: CarbonAPI
X-Powered-By: CarbonAPI
Content-Type: application/octet-stream
Content-Transfer-Encoding: Binary
Content-length: 104857600
Content-Disposition: attachment; filename=zero.bin
            

TOR Node

Endpoint: /tor

Returns whether or not the client is connecting through a TOR node.

$ curl https://carbon-api.tk/tor
{
    "origin": "123.123.123.123",
    "hostname": "exitnode.torproject.org",
    "tor_node": "true"
}
            

Host Location

Endpoint: /location

Returns the geographical information of the given host. If no host is specified, Carbon uses the client IP for the lookup.

Accepts fully-qualified domain names and IP (v4/v6) addresses as the host.

$ curl https://carbon-api.tk/location?host=1.1.1.1
{
  "location": {
    "ip": "1.1.1.1",
    "hostname": "1dot1dot1dot1.cloudflare-dns.com",
    "city": "Brisbane",
    "state_province": "Queensland",
    "country": "Australia",
    "ISO3166-1-alpha-2": "AU",
    "postal_code": 4000,
    "longitude": -27.4679,
    "latitude": 153.028,
    "google_maps": "https://www.google.com/maps/@-27.4679,153.028"
  }
}
            

Do Not Track

Endpoint: /dnt

Returns the status of the HTTP DNT header.

$ curl https://carbon-api.tk/dnt
{
    "DNT": "true"
}
            

HTTP Referer

Endpoint: /referer

Returns the contents of the HTTP Referer header.

$ curl https://carbon-api.tk/referer
{
    "referer": "https://duckduckgo.com/?q=carbonapi"
}
            

Delay

Endpoint: /delay

Delay the connection response for n seconds.

$ curl https://carbon-api.tk/delay?n=5
{
    "HTTP Response Code": "HTTP/1.1 200 OK",
    "response_delay": "5s"
}
            

UUID

Endpoint: /uuid

Generate valid RFC 4122 v4 compliant Universally Unique IDentifiers (UUID).

$ curl https://carbon-api.tk/uuid
{
    "uuid": "244650e9-715a-4946-be98-43872ae6b067"
}
            

OpenGraph

Endpoint: /opengraph

Return OpenGraph tags from url

$ curl https://carbon-api.tk/opengraph?url=https://carbon-api.tk/
{
    "og": {
        "locale": "en_US",
        "type": "article",
        "title": "Carbon",
        "description": "Free HTTP Request & Response Service.",
        "url": "https://www.carbon-api.tk",
        "site_name": "Carbon",
        "image": "https://www.carbon-api.tk/images/social.png",
        "image:width": 512,
        "image:height": 1024,
        "updated_time": "2017-10-05T18:10:04+00:00"
    }
}
            

Feedback

Endpoint: /feedback

Submit feedback on Carbon API.

$ curl https://carbon-api.tk/feedback -d name='John Doe' -d email='[email protected]' -d message='Hi Carbon!'
{
    "feedback": {
        "name": "John Doe",
        "email": "[email protected]",
        "message": "I love Carbon API!"
    },
    "status": "submitted"
}