Quickstart

This page helps you get up and running with the Maildrop API within ten minutes.

The Maildrop API is based on GraphQL, which allows for an easy HTTP API integration with your codebase. The maildrop.cc website uses the Apollo GraphQL client to access the API, and this document will help show how to create raw HTTP requests or use the prebuilt Apollo Javascript library.

See Also

Quickstart - curl

curl --request POST \
    --header 'content-type: application/json' \
    --url https://api.maildrop.cc/graphql \
    --data '{"query":"query Example {\n  ping(message:\"hello, world!\")\n}"}'

should return

{"data":{"ping":"pong hello, world!"}}

The API is hosted at https://api.maildrop.cc/graphql and only accepts POST requests, and these requests must have a Content-Type header set to "application/json".

Quickstart - React

  1. Install the Apollo React library into your project

  1. Set up the schema for your Apollo client

  1. Set up your GraphQL client object

  1. Set up a test GraphQL query

  1. Set up a component to run the query and display the results

You should see a page which returns the text "Return: pong Hello, world!". The Apollo library is extremely powerful, and takes care of the raw HTTP requests, authentication, caching, JSON parsing, and so on. It acts as a React hook, so as the request starts, the loading boolean automatically changes, triggering a re-render, and then when the data comes in for the request, another re-render is automatically done.

The ping resolver returns whatever message you send to it appended to the word "pong". Try it out! GraphQL queries can take a variable as an argument to the resolver, which is specified in the schema in step 2. That schema is the exact schema which maildrop.cc uses to access the API.

Last updated