> This page is for Applications Protection.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.humansecurity.com/llms.txt.

# Code examples

You can leverage the Code Defender API to retrieve a variety of data about your application. Below are examples of how you can use the API for different scenarios.

## Get all incidents in the past month for all applications

1. Request the account's overall data. This returns an object with different account data. One of the fields, named applications, holds all the applications that were ever enabled on Code Defender.

```curl
curl --request GET \
     --url https://api-gw.perimeterx.com/v1/account-settings \
     --header 'accept: application/json'
```

2. With the array from **Step 1**, you can extract all `app_id`s.

```javascript
const appIds = accountSettingsresult.applications.map(application => application.app_id);
```

3. After obtaining all relevant app Ids, you can easily request all incidents using start and end timestamps from the past month. This example shows timestamps for the full month of April 2023.

```javascript
const incidentsPerAppId = Promise.All(
	appIds.map(appId => 
		fetch(
    	`https://api-gw.perimeterx.com/v1/incidents?appId=${appId}&tld=example.com&from=1680307200000&to=1682899199000&take=20&skip=0`, headers: { Authentication: 'Bearer ' } 
    )
  ) 
)
```