Quickstart :)

This guide will get you all set up and ready to use the n_2 API. We’ll cover how to connect your ads accounts and how to make your first API request.

Creating an account

We are currently in closed alpha and don't allow account creation.

If you want to join the alpha, please fill out the form on our homepage. If you received login credentials from us, you are good to go.

Connecting your ads accounts

Connecting your ads accounts is easy. You can do it from the dashboard.

Connecting from the dashboard

  1. Go to the dashboard and click on the Platforms tab.
Platforms tab in the dashboard
  1. Click on the Connect button next to the platform you want to connect. For example, if you want to connect your Facebook account, click on the Continue with Facebook button.
  2. Follow the instructions on the screen to connect your account. For Facebook, you will be redirected to Facebook to log in and authorize n_2 to access your account. Notice that n_2 will only request permissions that are necessary to access and manage your ads accounts.
Facebook login screen
  1. After you have successfully connected your account, you should see a success screen like the following.
Facebook success screen
  1. Go back to the Platforms tab in the dashboard, and you should see your connected account. Notice that in this example, the Facebook platform is now connected. The button has changed to Disconnect from Facebook. Feel free to click this button again to revoke all access granted to your accounts.
Facebook connected in the dashboard

Connecting via the API

This feature is still work in progress. Please use the dashboard for now.

Creating an API token

To make requests to the n_2 API, you need to create an API token. You do so by sending a POST request to the /auth/login endpoint with your login credentials.

POST
/auth/login
curl -X POST https://api.n2api.io/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "you@yourdomain.com",
    "password": "yourpassword"
  }'

You should get a response that looks something like this

{
  "access_token": "eyJhbGciOiJIUzI1NiIsskXCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwisdasidI2MDU4MTAwLCJpYXQiOjE3MjYwNTQ1MDAsInN1YiI6ImE3ZWI4NDJkLWNiYTMtNGY2Mi04NzMwLTNmNGNiOTRmMDUwNyIsImVtYWlsIjoidXNlckBleGFtcGxlLmNvbSIsInBob25lIjoiIiwiYXBwX21ldGFkYXRhIjp7InByb3ZpZGVyIjoiasdUUsiLCJwcm92aWRlcnMiOlsiZW1haWwiXX0sInVzZXJfbWV0YWRhdGEiOnt9LCJyb2xlIjoiYXV0aGVudGljYXRlZCIsImFhbCI6ImFhbDEiLCJhbXIiOlt7Im1ldGhvZCI6InBhc3N3b3JkIiwidGltZXN0YW1wIjoxNzI2MDU0NTAwfV0sInNlc3Npb25faWQiOiI2YjY1MzgwMi04NGVkLTRjY2QtODkwNS04NDA4YTA1YmE3ZTIifQ.OO274DI2Iv4DasdvIxAPKmiBFvFTY54_5BAFJNjiww",
  "token_type": "bearer",
  "expires_in": 3600,
  "refresh_token": "HIa48UYusXuOpdjhwc8iDA"
}

You can now use the access_token to make requests to the API. The token is valid for 1 hour. If you need a new token, you currently have to log in again. We are working on a refresh token feature.

Making your first API request

The first request we want to make is to the Platforms endpoint. This endpoint will return a list of all the platforms you have connected to your account.

GET
/platform
curl -G https://api.n2api.io/platform \
  -H "Authorization: Bearer {token}"

You should get a response that looks something like this:

[
  {
    "name": "Pinterest",
    "description": "Pinterest is an image sharing and social media service designed to ...",
    ...
  },
  {
    "name": "Facebook",
    "description": "Facebook is an American online social media and social networking service ...",
    ...
  },
  ...
]

Accessing the auto generated API sandbox

We provide a Swagger / OpenAPI documentation for the API. You can access it by visiting https://api.n2api.io/api. This sandbox presents all API endpoints to you. Go to the Auth section and click on the POST /auth/login endpoint. You can then click on the Try it out button and enter your login credentials to get a token. Copy this token and click on the Authorize button in the top right corner. Enter the token in the Value field and click Authorize. After that, you can try out any endpoint in the API. For example, you can go to the Platforms section and click on the GET /platform endpoint. Click on the Try it out button and you should see the response from the API.

Swagger documentation

What's next?

Great, you're now set up with an API client and have made your first request to the API. Here are a few links that might be handy as you venture further into the n_2 API:

Was this page helpful?