Getting started

Client credentials

There are several ways how you can authenticate to the Monerium API. In the following example, you will be using a Sandbox version of the system with client credentials which you can use to test and understand how this fits into your platform.

Getting an access token

When you sign up to create an application, you will receive a client_id and a client_secret. If you don't have one already, you can follow along by using the sample credentials in the example below. Now, let's use those to fetch the access_token.

Click the 'Fetch access token' button in the CodeSandbox example below.

Now that you've got an access token, you can authenticate against the Monerium EMI API. Behind the scenes is the following request.

curl 'https://api.monerium.dev/auth/token' \
  -d client_id=1234567890abcdef \
  -d client_secret=1234567890abcdef1234567890abcdef \
  -d grant_type=client_credentials

API documentation:
POST /auth/token

Getting profiles

An application can access multiple profiles. Let's see how you can find and fetch those profiles.

First, you'll need the authentication context that contains the information about your user and which profiles you can access. Use the access token you retrieved in the example above and click 'Fetch authentication context.'

Request:
 curl -H 'Authorization: Bearer YOUR-ACCESS-TOKEN'
  'https://api.monerium.dev/auth/context'
Response:
{
  userId: "d92e9039-0773-11ed-8b1f-4a76448b7b21",
  email: "[email protected]",
  name: "[email protected]",
  roles: [],
  auth: {
     method: "password",
     subject: "[email protected]",
     verified: true
  },
  defaultProfile: "d88499e4-0773-11ed-8b1f-4a76448b7b21",
  profiles: [
     {
        id: "d88499e4-0773-11ed-8b1f-4a76448b7b21",
        kind: "personal",
        name: "[email protected]",
        perms: [
           "read",
           "write"
        ]
     }
  ]
}

API documentation:
GET /auth/context

You have access to all of the profiles listed in the profiles array. Let's fetch further details on the profile by grabbing the first profile id.

Getting profile detail

Request:
 curl -H 'Authorization: Bearer YOUR-ACCESS-TOKEN'
  'https://api.monerium.dev/profiles/2b3933cf-d7f7-11eb-843f-bad551e4b9a5'
Response:
{
  id: "d88499e4-0773-11ed-8b1f-4a76448b7b21",
  name: "[email protected]",
  kyc: {
     state: "absent",
     outcome: "unknown"
  },
  accounts: [
     ...,
     {
        id: "6da0137e-07a7-11ed-8b1f-4a76448b7b21",
        address: "0xfd47C71B650d3445B657a3a864762b1F907f2041",
        currency: "eur",
        chain: "ethereum",
        network: "rinkeby"
     },
     {
        id: "6db0afb6-07a7-11ed-8b1f-4a76448b7b21",
        address: "0xfd47C71B650d3445B657a3a864762b1F907f2041",
        currency: "eur",
        chain: "polygon",
        network: "mumbai",
        iban: "FI54 9532 0029 2243 50",
        standard: "iban"
     }
  ]
}

API documentation:
GET /profiles/{profileId}

For the demo, most of the profile's accounts have been omitted. When connecting a wallet, a profile will obtain eight accounts. EUR, GBP, USD, and ISK for both Ethereum and Polygon.

Note that this profile already has an IBAN attached to his Polygon account.

Summary


What's next?

You've now learned how to authenticate against the API. You can now dig deeper into the documentation and read about different ways to authenticate and authorize, learn how to place and retrieve orders, and more.