Bypass Censorship API

Introduction

The Bypass Censorship API allows publishers to interact with the Bypass Censorship platform and to obtain short links, snapshot links, and mirror links for their content.

Note

This documentation is generic and applies to any deployment of the Bypass Censorship platform. For the base URL and authentication details specific to your use, contact your vendor.

The API supports the following endpoints:

Endpoint

Method

Description

/me

GET

Retrieve information about the authenticated user’s pool.

/link

GET

Generate a short link or a direct mirror link.

/<hash>

GET

Redirect to the live mirror associated with the given hash.

Authentication

The API endpoints are protected by authentication. The authentication method depends on the endpoint:

  • /me endpoint: The API key is provided in the request arguments using the key parameter. If no API key is provided, the “public” resource pool is used.

  • /link endpoint: The API key is provided in the request arguments using the key parameter. If no API key is provided, the “public” resource pool is used.

Endpoints

/me

Retrieve information about the authenticated user’s pool.

  • Method: GET

  • URL: /me

Query Parameters:

  • key (optional): The API key of the pool. If not provided, the public API key is used.

Response:

  • Success: Returns the information about the pool in JSON format.

  • Failure: Returns a 403 response if the API key is invalid.

/<hash>

Redirect to the live mirror associated with the given hash.

  • Method: GET

  • URL: /<hash>

Path Parameters:

  • hash (required): The hash associated with the short link.

Query Parameters:

  • force (optional): Always redirect to a mirror and ignore GeoIP information.

  • force_ip (optional): Override the client IP address and base the GeoIP lookup on this IP address instead.

Response:

  • Success: Redirects the client to the original URL.

  • Failure: Returns a 404 response if the hash is invalid or not found.

Example Usage

$ curl -X GET /me?key=<api_key>
$ curl -X GET /link?url=<url>&type=<type>&key=<api_key>
$ curl -X GET /<hash>

Note: Replace <api_key>, <url>, <type>, and <hash_> with actual values.

Authentication and Permissions

The API endpoints require valid API keys for authentication. The API key can be obtained from the pool configuration.

API keys have different permissions:

  • Public API Key: Can be used to access live mirror links, snapshots, and resolve short links.

  • Private API Key: Can be used to access live mirror links, snapshots, and create new short links.

Response Format

The API endpoints return JSON responses. Successful responses contain the requested data, while failure responses provide relevant error messages.

Error Handling

In case of errors, the API endpoints return appropriate HTTP status codes and error messages. Clients should handle these errors gracefully and take appropriate actions.