> For the complete documentation index, see [llms.txt](https://apidocs.arionbanki.is/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.arionbanki.is/business-apis/cards-api/cards-api-quick-start.md).

# Cards API Quick Start

All the information you need to fetch data from the Cards API

List cards, get card details or transaction history.

## API authentication

First things first, follow the instructions in the link to get all the necessary prerequisites to fetch data from the cards API.

{% columns %}
{% column %}

#### Production

Fetching data from the production environment requires:

* **API key**
* **Búnaðarskilríki certificate**
* **Auth Token**
  {% endcolumn %}

{% column %}

#### Sandbox

Fetching data from the sandbox environment requires:

* **API key**
* **Sandbox Token**
  {% endcolumn %}
  {% endcolumns %}

{% columns %}
{% column %}
Here's a guide on how to get them for production.

{% content-ref url="/pages/0RJ5SYumtOLMmoli2EdC" %}
[Production](/business-apis/authentication/production.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Here's a guide on how to get them for sandbox.

{% content-ref url="/pages/0lWYnBPAgrudG7Q5Sw76" %}
[Sandbox](/business-apis/authentication/sandbox.md)
{% endcontent-ref %}
{% endcolumn %}
{% endcolumns %}

***

## Available methods

Here is what the Cards API offers. Clicking on a method delivers the API Reference for that endpoint.

{% columns %}
{% column %}
[List of cards](/business-apis/cards-api/cards-api-reference-1.md#get-api-v1-cards)

[Card details](/business-apis/cards-api/cards-api-reference-1.md#get-api-v1-cards-cardid)

[Card transactions](/business-apis/cards-api/cards-api-reference-1.md#get-api-v1-cards-cardid-transactions)
{% endcolumn %}

{% column %}

{% endcolumn %}
{% endcolumns %}

***

## Calling the Cards API

The base URL for production is <https://apigw.arionbanki.is/cards>

The base URL for sandbox: <https://apigwsandbox.arionbanki.is/cards>

Take a look at how you might call the **query cards** method using `curl`  or other popular programming languages, note that these examples are to connect to the production environment.

Note that if you're trying this endpoint for the first time, expect the results to be empty, because you might not have any cards yet, but with status code <mark style="color:$success;">200 OK.</mark>

What you need is:

* **Búnaðarskilríki Certificate** location and it's **password,** see [here](/business-apis/authentication/production.md#certificate).
* **API key** from the [developer portal](/business-apis/authentication/production.md#get-your-api-key)
* **Auth key** from the [authentication service](/business-apis/authentication/production.md#authorization) or **Token** if you're connected to the [sandbox env.](/business-apis/authentication/sandbox.md#user-authorization-on-sandbox)
* A random **UUID** to use as a request id.

{% tabs %}
{% tab title="curl" %}
{% code fullWidth="false" %}

```bash
curl --cert <Directory of cert>/cert.pfx:<cert password> --cert-type P12 \
    -H "accept: application/json" \
    -H "X-Request-ID: <uuid for request>" \
    -H "Ocp-Apim-Subscription-Key: <API key>" \
    -H "Authorization: Bearer <auth key from the auth service>" \
    -X GET "https://apigw.arionbanki.is/cards/api/v1/cards"

```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
import requests
import uuid
import ssl
import tempfile
import os
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption
from cryptography.hazmat.primitives.serialization.pkcs12 import load_pkcs12

CERT_PATH = "<directory of cert>/cert.pfx"
CERT_PASSWORD = "<cert password>"
SUBSCRIPTION_KEY = "<API key from Developer portal>"
BEARER_TOKEN = "<Auth Key from Auth service>"

# requests doesn't natively support .pfx — convert to PEM first or use ssl context
def load_pfx_as_pem_files(pfx_path: str, password: str):
    with open(pfx_path, "rb") as f:
        pfx_data = f.read()

    p12 = load_pkcs12(pfx_data, password.encode())

    cert_pem = p12.cert.certificate.public_bytes(Encoding.PEM)
    key_pem = p12.key.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())

    cert_file = tempfile.NamedTemporaryFile(delete=False, suffix=".pem")
    key_file = tempfile.NamedTemporaryFile(delete=False, suffix=".pem")

    cert_file.write(cert_pem)
    key_file.write(key_pem)
    cert_file.close()
    key_file.close()

    return cert_file.name, key_file.name

cert_pem_path, key_pem_path = load_pfx_as_pem_files(CERT_PATH, CERT_PASSWORD)

response = requests.get(
    url="https://apigw.arionbanki.is/cards/api/v1/cards",
    headers={
        "Accept": "application/json",
        "X-Request-ID": str(uuid.uuid4()),
        "Ocp-Apim-Subscription-Key": SUBSCRIPTION_KEY,
        "Authorization": f"Bearer {BEARER_TOKEN}",
    },
    cert=(cert_pem_path, key_pem_path),
)
print(response.json())
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import axios from "axios";
import https from "https";
import fs from "fs";
import { randomUUID } from "crypto";

const agent = new https.Agent({
  pfx: fs.readFileSync("/path/to/cert.pfx"),
  passphrase: "<your-cert-password>",
});

const response = await axios.get(
  "https://apigw.arionbanki.is/cards/api/v1/cards",
  {
    httpsAgent: agent,
    headers: {
      Accept: "application/json",
      "X-Request-ID": randomUUID(),
      "Ocp-Apim-Subscription-Key": "<your-subscription-key>",
      Authorization: "Bearer <your-bearer-token>",
    },
  }
);
console.log(JSON.stringify(response.data, null, 2));


```

{% endtab %}

{% tab title="C#" %}

```csharp
using System.Security.Cryptography.X509Certificates;

var certPath = "<Directory of cert>/cert.pfx";
var certPassword = "<cert password>";
var subscriptionKey = "<API key>";
var bearerToken = "<auth key from the auth service>";

var cert = new X509Certificate2(certPath, certPassword);

var handler = new HttpClientHandler();
handler.ClientCertificates.Add(cert);

using var client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("X-Request-ID", Guid.NewGuid().ToString());
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {bearerToken}");

var url = "https://apigw.arionbanki.is/cards/api/v1/cards";

var response = await client.GetAsync(url);
var body = await response.Content.ReadAsStringAsync();

Console.WriteLine($"Status: {response.StatusCode}");
Console.WriteLine(body);
```

{% endtab %}
{% endtabs %}

***

### API documentation

Look at the whole documentation to view all endpoints and possibilities how to use this service.

{% content-ref url="/pages/fTtWH7K1Nt9GvPD7PCJJ" %}
[Cards API Reference](/business-apis/cards-api/cards-api-reference-1.md)
{% endcontent-ref %}

***

## Use Our Sample Clients

Check out our sample clients if you want an example of usage:

{% columns %}
{% column %}
Here's a guide on how to get Postman set up against our services:

{% content-ref url="/pages/Qf4oYxCJ7tayE0YVbEMa" %}
[Postman Examples](/business-apis/examples/postman-examples.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Here's an example of a .NET client if you prefer that;

{% content-ref url="/pages/R5GwZIHeTwiKK8nehodk" %}
[.NET Sample Clients](/business-apis/examples/.net-sample-clients.md)
{% endcontent-ref %}
{% endcolumn %}
{% endcolumns %}
