import Moonbase from '@moonbaseai/sdk';
const client = new Moonbase({
apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const itemSearchResponse of client.collections.items.search('collection_id', {
filter: {
op: 'and',
filters: [
{
op: 'starts_with',
field: 'name',
value: 'C',
},
{
op: 'ends_with',
field: 'name',
value: 'e',
},
],
},
})) {
console.log(itemSearchResponse.data);
}require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
page = moonbase.collections.items.search("collection_id")
puts(page)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
page = client.collections.items.search(
collection_id="collection_id",
filter={
"op": "and",
"filters": [{
"op": "starts_with",
"field": "name",
"value": "C",
}, {
"op": "ends_with",
"field": "name",
"value": "e",
}],
},
)
page = page.data[0]
print(page.data)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
page, err := client.Collections.Items.Search(
context.TODO(),
"collection_id",
moonbase.CollectionItemSearchParams{
Filter: moonbase.ItemsFilterUnionParam{
OfAnd: &moonbase.ItemsFilterAndGroupParam{
Filters: []moonbase.ItemsFilterUnionParam{{
OfItemsFilterValueMatches: &moonbase.ItemsFilterValueMatchesParam{
Op: moonbase.ItemsFilterValueMatchesOpStartsWith,
Field: "name",
Value: moonbase.ItemsFilterValueMatchesValueUnionParam{
OfString: moonbase.String("C"),
},
},
}, {
OfItemsFilterValueMatches: &moonbase.ItemsFilterValueMatchesParam{
Op: moonbase.ItemsFilterValueMatchesOpEndsWith,
Field: "name",
Value: moonbase.ItemsFilterValueMatchesValueUnionParam{
OfString: moonbase.String("e"),
},
},
}},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request POST \
--url https://api.moonbase.ai/v0/collections/{collection_id}/items/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filter": {
"op": "and",
"filters": [
{
"op": "starts_with",
"field": "name",
"value": "C"
},
{
"op": "ends_with",
"field": "name",
"value": "e"
}
]
}
}
'{
"type": "list",
"data": [
{
"type": "search_result",
"data": {
"id": "1CLJt2v5aNd8G5SGzEaeVU",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Carmene"
},
"email": [
{
"type": "value/email",
"data": "person-2@example-2.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
},
{
"type": "search_result",
"data": {
"id": "1CLJt2v7opRhSWqVEtHwYT",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Cerise"
},
"email": [
{
"type": "value/email",
"data": "person-3@example-3.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
},
{
"type": "search_result",
"data": {
"id": "1CLJt2vA3GEGcxEhVY1EbS",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Charlie"
},
"email": [
{
"type": "value/email",
"data": "person-4@example-4.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
},
{
"type": "search_result",
"data": {
"id": "1CLJt2vCGi2qoPdukBiXeR",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Corinne"
},
"email": [
{
"type": "value/email",
"data": "person-5@example-5.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
}
],
"meta": {
"cursors": {}
}
}Search Collection Items
Returns a list of items in the collection that match the given filters.
import Moonbase from '@moonbaseai/sdk';
const client = new Moonbase({
apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const itemSearchResponse of client.collections.items.search('collection_id', {
filter: {
op: 'and',
filters: [
{
op: 'starts_with',
field: 'name',
value: 'C',
},
{
op: 'ends_with',
field: 'name',
value: 'e',
},
],
},
})) {
console.log(itemSearchResponse.data);
}require "moonbase"
moonbase = Moonbase::Client.new(api_key: "My API Key")
page = moonbase.collections.items.search("collection_id")
puts(page)import os
from moonbase import Moonbase
client = Moonbase(
api_key=os.environ.get("MOONBASE_API_KEY"), # This is the default and can be omitted
)
page = client.collections.items.search(
collection_id="collection_id",
filter={
"op": "and",
"filters": [{
"op": "starts_with",
"field": "name",
"value": "C",
}, {
"op": "ends_with",
"field": "name",
"value": "e",
}],
},
)
page = page.data[0]
print(page.data)package main
import (
"context"
"fmt"
"github.com/moonbaseai/moonbase-sdk-go"
"github.com/moonbaseai/moonbase-sdk-go/option"
)
func main() {
client := moonbase.NewClient(
option.WithAPIKey("My API Key"),
)
page, err := client.Collections.Items.Search(
context.TODO(),
"collection_id",
moonbase.CollectionItemSearchParams{
Filter: moonbase.ItemsFilterUnionParam{
OfAnd: &moonbase.ItemsFilterAndGroupParam{
Filters: []moonbase.ItemsFilterUnionParam{{
OfItemsFilterValueMatches: &moonbase.ItemsFilterValueMatchesParam{
Op: moonbase.ItemsFilterValueMatchesOpStartsWith,
Field: "name",
Value: moonbase.ItemsFilterValueMatchesValueUnionParam{
OfString: moonbase.String("C"),
},
},
}, {
OfItemsFilterValueMatches: &moonbase.ItemsFilterValueMatchesParam{
Op: moonbase.ItemsFilterValueMatchesOpEndsWith,
Field: "name",
Value: moonbase.ItemsFilterValueMatchesValueUnionParam{
OfString: moonbase.String("e"),
},
},
}},
},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
curl --request POST \
--url https://api.moonbase.ai/v0/collections/{collection_id}/items/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filter": {
"op": "and",
"filters": [
{
"op": "starts_with",
"field": "name",
"value": "C"
},
{
"op": "ends_with",
"field": "name",
"value": "e"
}
]
}
}
'{
"type": "list",
"data": [
{
"type": "search_result",
"data": {
"id": "1CLJt2v5aNd8G5SGzEaeVU",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Carmene"
},
"email": [
{
"type": "value/email",
"data": "person-2@example-2.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
},
{
"type": "search_result",
"data": {
"id": "1CLJt2v7opRhSWqVEtHwYT",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Cerise"
},
"email": [
{
"type": "value/email",
"data": "person-3@example-3.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
},
{
"type": "search_result",
"data": {
"id": "1CLJt2vA3GEGcxEhVY1EbS",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Charlie"
},
"email": [
{
"type": "value/email",
"data": "person-4@example-4.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
},
{
"type": "search_result",
"data": {
"id": "1CLJt2vCGi2qoPdukBiXeR",
"type": "item",
"collection": {
"id": "1CLJt2ubZ7zAZFBxUxeBHo",
"type": "collection",
"ref": "people"
},
"values": {
"name": {
"type": "value/text/single_line",
"data": "Corinne"
},
"email": [
{
"type": "value/email",
"data": "person-5@example-5.com"
}
],
"created_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
},
"updated_at": {
"type": "value/datetime",
"data": "2025-02-17T16:00:00.000Z"
}
}
}
}
],
"meta": {
"cursors": {}
}
}Authorizations
Your Moonbase API key.
Path Parameters
Query Parameters
When specified, returns results starting immediately before the item identified by this cursor. Use the cursor value from the response's metadata to fetch the previous page of results.
When specified, returns results starting immediately after the item identified by this cursor. Use the cursor value from the previous response's metadata to fetch the next page of results.
Maximum number of items to return per page. Must be between 1 and 100. Defaults to 20 if not specified.
1 <= x <= 100Body
Options to limit the item fields returned, sort the results, and filter which items are returned.
Include only specific fields in the returned items. Specify fields by id or key.
Include only items with a value in the given field that satisfies the op condition.
- Match Value
- Value Exists
- AND
- OR
- NOT
Show child attributes
Show child attributes
Sort items returned by the specified fields, specified directly by (name) or through relations (organization.name, deals.owner.email). Prefix with a hyphen/minus (-) to sort in descending order.
Response
Successful response.
A set of results using cursor-based pagination.

