> For the complete documentation index, see [llms.txt](https://docs.mburger.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mburger.cloud/how-to/advance-section-retrieval/filter-sections.md).

# Filter sections

## Filter by value

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://mburger.cloud/api/blocks/<id>/sections?filter[value]=example_value
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
```

{% endtab %}

{% tab title="iOS SDK" %}

```swift
let filterParameter = MBFilterParameter(field: "value",
                                        value: THE_VALUE)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { sections in
                                
                     },
                     failure: { error in
                                
                     })
```

{% endtab %}

{% tab title="Android SDK" %}

```kotlin
val arrayFilters = ArrayList<Any>()
filters.add(MBFilterParameter(key = THE_KEY, value = THE_VALUE))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
```

{% endtab %}

{% tab title="PHP SDK" %}

```php
$response = (new MBurger())->getSections($block_id)->filterByValue(array $values, string $element_name = null);
```

{% endtab %}

{% tab title="JS SDK" %}

```javascript
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghj",
});

instance.getBlock({
    block_id: 799,
    filter: {
        'value': 'flowers'
    }
}).then(result => console.log(result));
```

{% endtab %}

{% tab title="Flutter SDK" %}

```dart
MBFilterParameter filterParameter = MBFilterParameter(
  field: 'value',
  value: THE_VALUE,
);

MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);
```

{% endtab %}
{% endtabs %}

## Filter by an element value

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://mburger.cloud/api/blocks/<id>/sections?filter[element.value]=example_value
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
```

{% endtab %}

{% tab title="iOS SDK" %}

```swift
let filterParameter = MBFilterParameter(field: "value",
                                        name: ELEMENT_NAME,
                                        value: THE_VALUE)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { (sections, paginationInfo) in
                                
                     },
                     failure: { error in
                                
                     })
```

{% endtab %}

{% tab title="Android SDK" %}

```kotlin
val arrayFilters = ArrayList<Any>()
filters.add(MBElementFilterParameter(element_name= THE_ELEMENT_NAME, 
                                 value = THE_VALUE))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
```

{% endtab %}

{% tab title="PHP SDK" %}

```
// Work in progress
```

{% endtab %}

{% tab title="JS SDK" %}

```javascript
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghj",
});

instance.getBlock({
    block_id: 799,
    filter: {
        'value': 'element_name|element_value'
    }
}).then(result => console.log(result));
```

{% endtab %}

{% tab title="Flutter SDK" %}

```dart
MBFilterParameter filterParameter = MBFilterParameter.named(
  field: 'value',
  name: ELEMENT_NAME,
  value: THE_VALUE,
);

MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);
```

{% endtab %}
{% endtabs %}

## Filter by relation

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://mburger.cloud/api/blocks/<id>/sections?filter[relation]=<block_id>,<section_id>
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
```

{% endtab %}

{% tab title="iOS SDK" %}

```swift
let filterParameter = MBFilterParameter(field: "relation",
                                        value: RELATION_BLOCK_ID + "," + RELATION_SECTION_ID)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { (sections, paginationInfo) in
                                
                     },
                     failure: { error in
                                
                     })
```

{% endtab %}

{% tab title="Android SDK" %}

```kotlin
val arrayFilters = ArrayList<Any>()
filters.add(MBFilterParameter(key = "relation", 
                                 value = RELATION_BLOCK_ID 
                                 + "," + RELATION_SECTION_ID))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
```

{% endtab %}

{% tab title="PHP SDK" %}

```php
$response = (new MBurger())->getSections($block_id)->filterByRelation(int $block_id, int $section_id);
```

{% endtab %}

{% tab title="JS SDK" %}

```javascript
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghjk",
});

instance.getBlock({
    block_id: 798,
    filter: {
        'relation': 'RELATION_BLOCK_ID,RELATION_SECTION_ID'
    }
}).then(result => console.log(result));

```

{% endtab %}

{% tab title="Flutter SDK" %}

```dart
MBFilterParameter filterParameter = MBFilterParameter(
  field: 'relation',
  value: RELATION_BLOCK_ID + ',' + RELATION_SECTION_ID,
);

MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);
```

{% endtab %}
{% endtabs %}

## Filter by geofence

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://mburger.cloud/api/blocks/<id>/sections?filter[geofence]=latNE,latSW,lngNE,lngSW
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
```

{% endtab %}

{% tab title="iOS SDK" %}

```swift
let geofenceParameter = MBGeofenceParameter(NECoordinate: CLLocationCoordinate2D(NELat, NELng),
                                            SWCoordinate: CLLocationCoordinate2D(SWLat, SWLng))
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [geofenceParameter],
                     success: { (sections, paginationInfo) in
                                
                     },
                     failure: { error in
                                
                     })
}

```

{% endtab %}

{% tab title="Android SDK" %}

```kotlin
val arrayFilters = ArrayList<Any>()
filters.add(MBGeofenceParameter(latitudeNE = yourLatitudeNE,
                                longitudeNE = yourLongitudeNE,
                                latitudeSW = yourLatitudeSW,
                                longitudeSW = yourLongitudeSW))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
```

{% endtab %}

{% tab title="PHP SDK" %}

```php
$response = (new MBurger())->getSections($block_id)->filterByGeofence(float $latNE, float $latSW, float $lngNE, float $lngSW);
```

{% endtab %}

{% tab title="JS SDK" %}

```
```

{% endtab %}

{% tab title="Flutter SDK" %}

```dart
MBGeofenceParameter parameter = MBGeofenceParameter(
  northEastLatitude: NELat,
  northEastLongitude: NELng,
  southWestLatitude: SWLat,
  southWestLongitude: SWLng,
);
    
MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [parameter],
);
```

{% endtab %}
{% endtabs %}

## Filter by id

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://mburger.cloud/api/blocks/<id>/sections?filter[id]=example_id
-H "Accept: application/json" 
-H "X-MBurger-Token: <token>" 
-H "X-MBurger-Version: 3"
```

{% endtab %}

{% tab title="iOS SDK" %}

```swift
/*
SECTION_ID can be a single id or a list of ids, comma separated.
*/
let filterParameter = MBFilterParameter(field: "id",
                                        value: SECTION_ID)
MBClient.getSections(ofBlock: BLOCK_ID,
                     parameters: [filterParameter],
                     success: { sections in
                                
                     },
                     failure: { error in
                                
                     })
```

{% endtab %}

{% tab title="Android SDK" %}

```kotlin
val arrayFilters = ArrayList<Any>()
filters.add(MBFilterParameter(key = "id", 
                                 value = SECTION_ID))

val sectionsListener = object: MBSectionsResultListener{
            override fun onSectionsApiError(error: String) {
            }

            override fun onSectionsApiResult(sections: ArrayList<MBSection>, 
                                             block_id: Long, 
                                             paginationInfos: MBPaginationInfo) {
            }
        }
        
MBurgerTasks.askForSections(context = applicationContext, 
                         block_id = BLOCK_ID,
                         filters = arrayFilters,
                         getElements = true,
                         listener = sectionsListener)
```

{% endtab %}

{% tab title="PHP SDK" %}

```php
$response = (new MBurger())->getSections($block_id)->filterByIds(array $ids);
```

{% endtab %}

{% tab title="JS SDK" %}

```javascript
const mburger = require('mburger');

const instance = mburger.createClient({
    api_key: "123456789asdfghjk",
});

instance.getBlock({
    block_id: 798,
    filter: {
        'id': '1,2,3'
    }
}).then(result => console.log(result));

```

{% endtab %}

{% tab title="Flutter SDK" %}

```dart
/*
SECTION_ID can be a single id or a list of ids, comma separated.
*/
MBFilterParameter filterParameter = MBFilterParameter(
  field: 'id',
  value: SECTION_ID,
);
    
MBPaginatedResponse<MBSection> sections =
    await MBManager.shared.getSections(
  blockId: BLOCK_ID,
  parameters: [filterParameter],
);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mburger.cloud/how-to/advance-section-retrieval/filter-sections.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
