# Getting Started

### Create a basic API request

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FJlwAKBOuBEoie1dN0BWc%2Fimage.png?alt=media&#x26;token=3b9a0048-743c-476f-9f61-4a8a7f132d61" alt=""><figcaption></figcaption></figure>

On the Scandium API runner interface, you are able to create a new API request. To create an API request, you need to select the method of the request and provide the API URL (endpoint).

Press the Send button to initiate the request or press the Save button to save the request.

You can change the name/title of the request before and after saving:

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FwOdPSL3kXcRHYTkBf9a1%2Fimage.png?alt=media&#x26;token=78e221a4-8025-477f-b4f8-4c7008304627" alt=""><figcaption></figcaption></figure>

Enter the desired name for your test case and press the Save button.

#### Try an example request

Method Type: GET

API URL: <https://api.edudream.fr/location/country>

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2Fo9L84NRTygnfEu5kn86b%2Fimage.png?alt=media&#x26;token=369be592-eaf9-4c64-a42f-511cabc6f3ef" alt=""><figcaption><p>An API request with sample response</p></figcaption></figure>

#### Additional information on API requests

The Scandium API runner interface allows you to add additional information to your API requests where needed.

**Query parameters:** Can be added from the 'Params' tab

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FjXxVcmstVlSbR4DCHj5W%2Fimage.png?alt=media&#x26;token=6475f945-deb0-433e-b2d2-ad5ab508c374" alt=""><figcaption></figcaption></figure>

**Authorization:** Scandium supports multiple authorization types out of the box, including Bearer Token, Basic Auth, API Key, Digest Auth, Oauth 1.0

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FAcOkeyqCDqaMiji5ONkb%2Fimage.png?alt=media&#x26;token=dd04662f-13ea-47be-8f84-9c86103da895" alt=""><figcaption></figcaption></figure>

**Headers:** You can add several header key-values as required by your API

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FjpBwruwHzc8v5DhikUf5%2Fimage.png?alt=media&#x26;token=812772e9-aa36-4730-9dc6-a980a5230826" alt=""><figcaption></figcaption></figure>

**Body:** Scandium supports multiple body types as payload for your request. This includes: form-data, x-www-form-urlencoded, JSON, XML, Text, HTML and GraphQL.

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2Fta82FK2dJlPkOOsKJ7Ul%2Fimage.png?alt=media&#x26;token=7e829ae2-bb5d-4253-8fd8-bb223146dbd1" alt=""><figcaption></figcaption></figure>

### Adding assertions to API requests

When you make API requests, you want to validate that the request outcome meets your expectations. With Scandium API Runner, you can add assertions to your API tests. To add. these assertions, click on the 'Assertions' tab.

You can add assertions for the following:

* Status code
* Response header
* Response body type
* Response body content
* Request duration

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FGIdz8tNuE9KFCkI9SZ9E%2Fimage.png?alt=media&#x26;token=2949553b-fd5f-4ec9-8fe6-4d1b3e926972" alt=""><figcaption></figcaption></figure>

To add an assertion,&#x20;

1. Select the assertion type.
2. Select a condition for the assertion.
3. Input the value to be checked for.

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FgtLJj2O10dHXKdZZh0WF%2Fimage.png?alt=media&#x26;token=711270e8-2a39-4ccb-bf6e-76f5b7bde45d" alt=""><figcaption><p>Select assertion operator/condition</p></figcaption></figure>

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FgiuKgFLoVFJxuVzUwJ3y%2Fimage.png?alt=media&#x26;token=7c3731a0-6b8c-4ea6-83c6-34d187c5cf0c" alt=""><figcaption><p>Enter assertion value to check for</p></figcaption></figure>

You can also combine multiple assertions for one request.

### Viewing API Response

After sending your API requests, you can see the response to your requests in the tab below the request area.

This tab shows you the status code, the duration of the request, the size of the response and the content of the response. You can view the body of the response in JSON, look at the headers and also inspect the Assertions Result tab for result of the assertions you added.

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FsGtIcbfi5Ol3F1O4Elb3%2Fimage.png?alt=media&#x26;token=c6e37c45-cb1a-4bcb-98ab-5460deb2d78c" alt=""><figcaption><p>Response body</p></figcaption></figure>

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FCNffNfqJQSSxukVdWm8A%2Fimage.png?alt=media&#x26;token=be63bd86-79f7-4a57-910a-e07a2a0b85d1" alt=""><figcaption><p>Assertion result</p></figcaption></figure>

### Variables in requests

Variables make it easy to reuse a value in multiple API tests. For example, imagine the APIs you are testing have the base url `https://example.com/api`. This part of the URL is common to all endpoints, such that a login endpoint would like `https://example.com/api/login` while a registration endpoint would like `https://example.com/api/register`.

Now imagine you want to test these APIs across different environments such as staging, test and production, where all these environments have different base URLs. Normally, you'd have to update all test cases with the specific environment URL each time you want to run your API test against such environment.

But if you create the base URL as a variable, you'd only have to make the change once.

#### How to create a variable

You can create a variable by clicking on the Variable submenu

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FDQ4PzXKzGh3N3eSzq3lF%2Fimage.png?alt=media&#x26;token=05eec577-cf2a-482d-a462-2935750836ba" alt=""><figcaption></figcaption></figure>

From the modal that appears, you can then add the names and values for your variables. You can add as many variables as you need.

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FvCxtxiQ3ZSHTPQbdMYJF%2Fimage.png?alt=media&#x26;token=a41cf323-66e4-4329-b42a-96510fa47310" alt=""><figcaption></figcaption></figure>

Click on the Save button to save your newly added variable.

#### Using a variable (How to make reference to a variable)

Once you have created a variable, it will be available for you to use within your tests. Variables can be used in the endpoint field, headers, parameters and body of the request.

To reference a variable, type `{{` (two curly braces), this will bring up a suggestion of the list of variables available, you can then select one from the list.

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2F5U7r3cTcULRzIdE7BFlO%2Fimage.png?alt=media&#x26;token=b1d2f56c-c38b-4f7c-831e-1fd325f85bf3" alt=""><figcaption><p>Choose a variable from the suggestion</p></figcaption></figure>

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FZV0se0yF9tS2MEGc4LEd%2Fimage.png?alt=media&#x26;token=d221fee9-ca9e-46d2-a43a-4d9d54e795d5" alt=""><figcaption><p>Variable plus other string</p></figcaption></figure>

When  the request is sent,  the variable (denoted by `{{base_url}}`) will get replaced by its value which in this case is [`https://api.edudream.fr`](https://api.edudream.fr)&#x20;

### Dynamic values and functions in requests

When sending an API request, there could often be situations where you need to send a randomized value to your endpoint. For example, when testing a registration endpoint, you want to have a different email address value sent every time the request is made so that your application doesn't give you a "<mark style="color:red;">email already exists</mark>" error. This could also apply  to phone numbers, usernames etc.

Scandium makes it easy for you to achieve this dynamic data input. Similar to the variables in requests, dynamic functions also use the `{{ }}` notation.

You can use this dynamic values in your:

* URL
* Query parameter keys and values
* Header keys and values
* Body payload
* Cookies keys and values

To use the dynamic value in an accepted field, type the `{{` where the value is required

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2FeyDlGyBFKHCmG8Kgu3QZ%2Fimage.png?alt=media&#x26;token=c77a4686-dd45-49be-b7b6-925e42d31835" alt=""><figcaption><p>Type two opening curly braces</p></figcaption></figure>

A suggestion popup opens up from which you can then click on the 'Dynamic Values' button. Clicking on the button above shows you a modal containing multiple available functions you can choose from.

Below are the functions you can choose from:

**Email**: To help you generate unique emails. Useful in cases where you need to test signup flows and you need a unique email each time the test runs. e.g *<itKRJ.lkdhuz1bql@testmail.getscandium.com>*

**Num**: To help you generate numbers of any length. e.g *19660200324*

**Range**: To help generate a number within two boundaries. e.g *236*

**Alpha**: To generate letters of the alphabet. You can specify the number of letters needed and even which character set you want the letters to come from. e.g *itKRJ*

**Alphanum**: Similar to alpha, but also includes numbers in the generated value. e.g *JlU1ZZcr*

**Date**: To generate date value in a desired format. e.g *15/09/2023*

**Time**: Generate timestamp value (epoch time). e.g *1694463242839*

**Datetime**: To generate datetime value e.g *Mon Sep 11 2023 21:13:50 GMT+0100 (West Africa Standard Time)*

**Boolean***:* To generate one of *true* or *false*.

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2Fi4jw8iv9j9IqYngxJk73%2Fimage.png?alt=media&#x26;token=73d23d3c-a5ff-49a4-8a01-99055513cf6a" alt=""><figcaption></figcaption></figure>

**NB**: In JSON payload, you should still insert the dynamic function inside quotes

<figure><img src="https://224585108-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSNbCT5gfctrLuSLyRsMW%2Fuploads%2Fw0ZLV4uFyGgN2jVLdrzO%2Fimage.png?alt=media&#x26;token=30294ac0-e580-4c50-92b4-5a7cc2b6035a" alt=""><figcaption><p>Put dynamic functions in quote</p></figcaption></figure>
