With the Content API, you can make requests to retrieve data about any of your models within Builder. The Content API supports advanced query filtering with URL parameters to help you get exactly the data you need.
Use cases for querying data could include searches, populating content for a collection, or getting all links that meet certain criteria.
To access this data, write queries with dot notation and, optionally, MongoDB style operators.
For more details on querying, see the Querying Cheatsheet.
Note: Content published by Builder is immediately available to the Content API. If your application's visual interface does not reflect the changes you have made, check whether they have been published to the Content API.
To start using the Content API, make sure to import the Builder SDK into your project.
At the command line, use npm to install the Builder SDK:
npm install @builder.io/reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/react";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-svelteIn your code, be sure to import the SDK:
import { fetchOneEntry } from '@builder.io/sdk-svelte';At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-vueIn your code, be sure to import the SDK:
// use this if you're using Vue 2
import { fetchOneEntry } from '@builder.io/sdk-vue;At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-vueIn your code, be sure to import the SDK:
// use this if you're using Nuxt 2
import { fetchOneEntry } from '@builder.io/sdk-vue'
// OR use this one if you're using Nuxt 3
import { fetchOneEntry } from '@builder.io/sdk-vue/vue3';At the command line, install the Qwik SDK:
npm install @builder.io/sdk-qwikIn your code, be sure to import the SDK:
import { fetchOneEntry } from "@builder.io/sdk-qwik";At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-react-nativeIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react-native";Install the Builder Angular SDK:
npm install @builder.io/sdk-angularIn your code, be sure to import the SDK:
// in your myComponent.component.ts
import { Content, fetchOneEntry } from '@builder.io/sdk-angular';Install the Builder Angular SDK:
npm install @builder.io/sdk-angularIn your code, be sure to import the SDK:
// in your myComponent.component.ts
import { Content, fetchOneEntry } from '@builder.io/sdk-angular';At the command line, use npm to install the Builder plugin for Gatsby and the React SDK (the Builder SDK):
npm install @builder.io/gatsby @builder.io/reactIn your code, be sure to import the SDK:
import { buidler, BuilderComponent } from '@builder.io/react';At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdk-reactIn your code, be sure to import the SDK:
import { builder } from "@builder.io/sdk-react";There's no Builder SDK package dependency when using the HTML API directly. You need an HTTP client to access the API, whether it's built into your framework or installed separately.
Install the Builder Angular SDK:
npm install @builder.io/angularIn your code, be sure to import the SDK:
// in AppModule
import { BuilderModule } from '@builder.io/angular';At the command line, use npm to install the Builder SDK:
npm install @builder.io/sdkIn your code, be sure to import the SDK:
import { builder } from '@builder.io/sdk';To use the Builder Content API to retrieve data from your models, be sure to always provide the following request parameters in your queries:
- Required:
my-model-name(replace with your model's name) - Required:
apiKeyquery param (replace with your Public API Key)
As an example, you'd replace my-model-name with the name of your model, such as page, and YOUR_API_KEY with your own Public API Key.
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEYYou can learn about the response structure using the Builder API Explorer.
If your API responses are coming back empty when querying, try the following:
- Verify API Key format. You must
apiKey, notapikey. - Ensure you've passed necessary targeting conditions. If your content has targeting conditions (like
urlPath,device, or custom user attributes), you must pass the corresponding user attributes in your API request to receive a response. - Check your content's status. Verify that your content is published and currently active if it is scheduled.
Not all query parameters perform equally. To get the best response times from the Content API, structure your queries to take advantage of Builder's database indexing.
The two most performant targeting attributes are urlPath and locale. These fields are database-indexed, which means Builder can resolve matching content entries significantly faster when either or both are included in userAttributes.
import { builder } from "@builder.io/react";
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
locale: 'en-US',
},
})Including urlPath or locale when possible or logically relevant greatly improves performance. The majority of Builder content is targeted against at least one of these two attributes, and this pattern is heavily optimized at the infrastructure level.
The following tips can be used to improve efficiency when using the Content API.
- Always target by
urlPathorlocalewhen relevant. Queries that include these attributes consistently outperform queries that rely solely on other custom targeting attributes. - Avoid broad, untargeted queries at runtime. Using
noTargeting: trueor omittinguserAttributesentirely fetches all entries without the benefit of indexing. Reserve these patterns for build-time use cases like static generation. - Use
fieldsandomitto reduce payload size. Returning only the fields you need reduces both response time and bandwidth. - Use
cachebust: trueonly at build time. Bypassing the cache produces the freshest data but significantly increases response times. Do not use it for runtime requests. - Lean on stale-while-revalidate caching. Builder serves content from the CDN edge cache while revalidating in the background. Keep
staleCacheSecondshigh for low-traffic content to maximize this benefit.
If your API responses are missing entries or returning fewer results than expected, the following patterns are common causes.
- Draft entries do not have targeting. Draft entries in a model that have no targeting rules configured can interfere with query results. Review your model for unfinished draft entries and either configure targeting for them or remove them.
- Your content is expired. A large volume of expired entries can affect query performance and skew results. Use
excludeExpired: trueto filter these out, or addstartDate/endDatefilters in yourqueryparam to scope results to an active date range. - Your cache is stale. If you've recently published changes that aren't appearing, the CDN cache may be serving an older version. Use
cachebust: trueto bypass the cache and confirm the latest data. Only use this for debugging or build-time use, not runtime requests. - Pagination is limiting the response. The default
limitis 30 and the maximum per request is 100. If your model has more entries than that, uselimitandoffsettogether to paginate through all results.
This section covers the available Builder Content API query params.
Use your API key when integrating with Builder.
import { builder } from "@builder.io/react";
builder.init(YOUR_API_KEY);import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { builder } from "@builder.io/react";
builder.init(YOUR_API_KEY);import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { builder } from "@builder.io/react";
builder.init(YOUR_API_KEY);import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { builder } from "@builder.io/react";
builder.init(YOUR_API_KEY);import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { builder } from "@builder.io/react";
builder.init(YOUR_API_KEY);import { fetchOneEntry } from '@builder.io/sdk-svelte';
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { fetchOneEntry } from "@builder.io/sdk-vue";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { fetchOneEntry } from "@builder.io/sdk-vue";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
await fetchOneEntry({
...
apiKey: YOUR_API_KEY
...
})export class myComponent {
content: BuilderContent | null = null;
async ngOnInit() {
const content = await fetchOneEntry({
apiKey: /* ADD YOUR PUBLIC API KEY HERE */,
model: /* ADD YOUR MODEL NAME */,
});
this.content = content;
}
}
export const myComponentResolver: any => {
...
return fetchOneEntry({
apiKey: /* YOUR PUBLIC API KEY HERE */
});
};Notice that Gatsby uses publicAPIKey rather than apiKey.
//gatsby-config.js
import { buidler, BuilderComponent } from '@builder.io/react';
module.exports = {
plugins: [
{
resolve: '@builder.io/gatsby',
options: {
// Replace with your Public API Key
publicAPIKey: YOUR_API_KEY,
},
},
],
};Notice that Gatsby uses publicAPIKey rather than apiKey.
//gatsby-config.js
...
module.exports = {
plugins: [
{
resolve: '@builder.io/gatsby',
options: {
// Replace with your Public API Key
publicAPIKey: YOUR_API_KEY,
},
},
],
};The apiKey query param is required, as in the following example where YOUR_API_KEY is your Public API Key.
&apiKey=YOUR_API_KEYFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEYimport { BuilderModule } from '@builder.io/angular';
@NgModule({
...
imports: [
...
BuilderModule.forRoot(YOUR_API_KEY),
],
})import { builder } from '@builder.io/sdk';
builder.init(YOUR_API_KEY);The following video demonstrates installing the React SDK:
Set it to true include references and Symbols in the response, ensuring consistency between the Visual Editor and the live site.
For more information on enrich, read Fetching References and Symbols with enrich.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('model', {
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('model', {
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('model', {
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
options: { enrich: false } // defaults to `true`
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
enrich: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('model', {
...
options: { enrich: true }
...
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
await fetchOneEntry({
...
enrich: true
...
})import { fetchOneEntry } from "@builder.io/sdk-vue";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-vue";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
await fetchOneEntry({
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
await fetchOneEntry({
...
options: { enrich: true }
...
})export class myComponent {
content: BuilderContent | null = null;
async ngOnInit() {
const content = await fetchOneEntry({
//define enrich inside options object
options: {
enrich: true;
}
});
this.content = content;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
//set enrich inside 'options' obj
options: {
enrich: true
}
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('model', {
...
options: { enrich: true }
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
await fetchOneEntry({
...
options: { enrich: true }
...
})&enrich=trueFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&enrich=trueimport { BuilderModule } from '@builder.io/angular';
// replace model with your model name
builder.get('model', {
options: { enrich: true }
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('model', {
options: { enrich: true }
})The following video demonstrates installing the React SDK:
When enriching data from the Content API, you may wish to exclude some fields or include only specific fields. When enrich is set to true, use the enrichOptions key to define precisely what information to receive.
enrichOptions accepts an object with two possible values:
- model: This key expects an object where each key is the name of a Model and each value is an object. Each object should include either the
fieldskey, representing which fields to include, theomitkey, representing which fields to exclude, or both keys. - enrichLevel: This key accepts a value greater than 0 and determines the depth level for enriching. For example, an
enrichLevelof 1 would return one additional nested model within the original response. The max level is 4.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is excluded.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-svelte";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-vue";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-vue";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-qwik";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
export class myComponent {
content: BuilderContent | null = null;
async ngOnInit() {
const content = await fetchOneEntry({
//define enrich inside options object
options: { enrich: true },
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
}
});
this.content = content;
}
}The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
export const myComponentResolver: any => {
...
return fetchOneEntry({
options: { enrich: true },
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
}
});
};The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
});The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
&enrich=true&enrichOptions.model.navigation.fields=id,name,data&enrichOptions.model.navigation.omit=data.titleThe example above demonstrates a request to a navigation model. The id, name, and data fields are included in the response. However, from the data field, the data.title is omitted.
import { BuilderModule } from "@builder.io/angular";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
import { builder } from "@builder.io/sdk";
const entry = await builder.get('post', {
...
options: {
enrich: true,
enrichOptions: {
model: {
author: {
fields: "id,name,data",
omit: "data.blocks",
},
category: {
fields: "id,name",
},
},
enrichLevel: 2,
},
},
...
})The example above demonstrates a request to a post model with two nested models: author and category. For author, the name, id, and data values are included in the response, except the data.blocks value is exclude.
For the category model, only id and name are included in the response. Finally, with enrichLevel set to 2, two additional levels of depth will be included within the response, nested within the post model.
Adding this key to your request returns a totalCount key with the total number of results for the model. This number can be used for pagination or other use-cases where the total number of results is useful to know.
import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { fetchOneEntry } from "@builder.io/sdk-svelte";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { fetchOneEntry } from "@builder.io/sdk-vue";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { fetchOneEntry } from "@builder.io/sdk-vue";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { fetchOneEntry } from "@builder.io/sdk-qwik";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});export class myComponent {
content: BuilderContent | null = null;
async ngOnInit() {
const content = await fetchOneEntry({
fetchTotalCount: true,
// ...
});
this.content = content;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
fetchTotalCount: true,
// ...
});
};import { builder } from "@builder.io/react";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { fetchOneEntry } from "@builder.io/sdk-react";
const entry = await fetchOneEntry({
fetchTotalCount: true,
...
});&fetchTotalCount=trueimport { BuilderModule } from "@builder.io/angular";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})import { builder } from "@builder.io/sdk";
const entry = await builder.get('post', {
fetchTotalCount: true,
...
})MongoDB style query of your data.
import { builder } from '@builder.io/react'
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
import { fetchOneEntry } from '@builder.io/sdk-react';
const entry = await fetchOneEntry({
model: 'product',
apiKey: 'ADD_YOUR_PUBLIC_API_KEY_HERE',
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
import { fetchOneEntry } from '@builder.io/sdk-react'
const entry = await fetchOneEntry({
model: 'product',
apiKey: /* ADD YOUR PUBLIC API KEY HERE */
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});Builder supports the following operators: $eq $gt $in $lt $lte $ne $nin $and $not $or $nor $exists $type $elemMatch $gte $regex $options. For more information, including examples, see the Builder Querying Cheatsheet.
import { builder } from '@builder.io/react'
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
import { fetchOneEntry } from '@builder.io/sdk-react';
const entry = await fetchOneEntry({
model: 'product',
apiKey: 'ADD_YOUR_PUBLIC_API_KEY_HERE',
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
import { fetchOneEntry } from '@builder.io/sdk-react'
const entry = await fetchOneEntry({
model: 'product',
apiKey: /* ADD YOUR PUBLIC API KEY HERE */
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});Builder supports the following operators: $eq $gt $in $lt $lte $ne $nin $and $not $or $nor $exists $type $elemMatch $gte $regex $options. For more information, including examples, see the Builder Querying Cheatsheet.
import { builder } from '@builder.io/react'
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
import { fetchOneEntry } from '@builder.io/sdk-react';
const entry = await fetchOneEntry({
model: 'product',
apiKey: 'ADD_YOUR_PUBLIC_API_KEY_HERE',
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
import { fetchOneEntry } from '@builder.io/sdk-react'
const entry = await fetchOneEntry({
model: 'product',
apiKey: /* ADD YOUR PUBLIC API KEY HERE */
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
import { fetchOneEntry } from '@builder.io/sdk-react';
const entry = await fetchOneEntry({
model: 'product',
apiKey: 'ADD_YOUR_PUBLIC_API_KEY_HERE',
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
import { fetchOneEntry } from '@builder.io/sdk-react'
const entry = await fetchOneEntry({
model: 'product',
apiKey: /* ADD YOUR PUBLIC API KEY HERE */
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});import { builder } from '@builder.io/react'
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
import { fetchOneEntry } from '@builder.io/sdk-react';
const entry = await fetchOneEntry({
model: 'product',
apiKey: 'ADD_YOUR_PUBLIC_API_KEY_HERE',
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
import { fetchOneEntry } from '@builder.io/sdk-react'
const entry = await fetchOneEntry({
model: 'product',
apiKey: /* ADD YOUR PUBLIC API KEY HERE */
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});Builder supports the following operators: $eq $gt $in $lt $lte $ne $nin $and $not $or $nor $exists $type $elemMatch $gte $regex $options. For more information, including examples, see the Builder Querying Cheatsheet.
import { builder } from '@builder.io/react'
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
})
// get all the entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await fetchOneEntry({
model: 'page',
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
})
// get all the entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
fetchOneEntry({
model: 'page',
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
})
// get all the entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await fetchOneEntry({
model: 'page',
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
})The following is the same for Qwik, Vue, Solid, Svelte, React (beta) or React-Native SDK:
import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
})
// get all the entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await fetchOneEntry({
model: 'page',
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
})
import { fetchOneEntry } from '@builder.io/sdk-react-native'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
})
// get all the entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await fetchOneEntry({
model: 'page',
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
})When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel
export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});
this.content = entry;
}
}This example retrieves an entry where the id matches abc123 and store it in this.content.
Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});
this.content = entry;
}
}When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});
this.content = entry;
}
}This example retrieves an entry where the id matches abc123 and store it in this.content.
Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});
this.content = entry;
}
}import { builder } from '@builder.io/react'
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});When using the query field in fetchOneEntry(), you can filter and retrieve entries based on any fields in the JSON structure returned by Builder that match the value provided to the query.
This includes:
- Standard fields such as
id,name,meta,data, andlastUpdated - Any custom fields defined in your model, for example, a
productmodel.
import { fetchOneEntry } from '@builder.io/sdk-react';
const entry = await fetchOneEntry({
model: 'product',
apiKey: 'ADD_YOUR_PUBLIC_API_KEY_HERE',
query: {
id: 'abc123' // `id` is a top-level field in the Builder response
}
});Combine multiple query conditions to filter content more precisely. For example, query fields within the data object.
import { fetchOneEntry } from '@builder.io/sdk-react'
const entry = await fetchOneEntry({
model: 'product',
apiKey: /* ADD YOUR PUBLIC API KEY HERE */
query: {
// `data` is a field present in the JSON response object from Builder
data: {
// `copy` and `price` are the custom fields defined in data model
'copy.$regex': 'Sample copy',
'price.$lt': 500
}
});Builder supports the following operators: $eq $gt $in $lt $lte $ne $nin $and $not $or $nor $exists $type $elemMatch $gte $regex $options. For more information, including examples, see the Builder Querying Cheatsheet.
&query.id=abc123
&query.data.myCustomField=someValue
&query.data.someNumber.$ne=20
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is the ID of your Symbol
&query.meta.symbolsUsed.SYMBOL_ID=true
For example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&query.meta.symbolsUsed.SYMBOL_ID=true// replace model with your model name
builder.get('model', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
id: 'abc123',
data: {
myCustomField: 'someValue',
someNumber: { $ne: 2 }
}
}
}
// to get all entries from a page model that are using a specific symbol
// where SYMBOL_ID is your Symbol's ID
const entry = await builder.get('page', {
query: {
'meta.symbolsUsed.SYMBOL_ID': true
}
});The following video demonstrates installing the React SDK:
Use it to specify targeting attributes, such as urlPath, device, and any of the defined custom targeting, to fetch the most relevant entry when the model contains multiple entries.
By default, the response is limited to one entry. Without targeting attributes, it will only include the topmost entry.
If you pass in a date value to the date param, you can override Builder's default behavior, which uses the server's current time.
For more details on user attributes, read targeting content. For important information regarding targeting and scheduling and the Content API, see Scheduling behavior later in this document.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})import { fetchOneEntry } from '@builder.io/sdk-react-native'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true,
// optional date param for scheduling
date: "12-01-2025"
},
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})&userAttributes.device=desktop
&userAttributes.urlPath=/about
&userAttributes.userLoggedIn=trueFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&userAttributes.device=desktop// replace model with your model name
builder.get('model', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
userAttributes: {
urlPath: '/about',
device: 'desktop',
userLoggedIn: true
},
})The following video demonstrates installing the React SDK:
Only include the specified fields from the response.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})import { fetchOneEntry } from '@builder.io/sdk-react-native'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
fields: 'id,name,data.customField'
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
fields: 'id,name,data.customField'
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
fields: 'id,name,data.customField'
}
})&fields=id,name,data.customFieldFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&fields=id,name,data.customField// replace model with your model name
builder.get('model', {
fields: 'id,name,data.customField'
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
fields: 'id,name,data.customField'
})The following video demonstrates installing the React SDK:
Exclude only specific fields from the response and return everything else.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data, bigField, data.blocks'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data, bigField, data.blocks'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data, bigField, data.blocks'
}
})When omit is used alongside fields, the response will include only the fields specified in fields and then exclude the fields specified in omit from that subset.
Use caution when combining these options to ensure the desired fields are included or excluded correctly in the response.
import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data, bigField, data.blocks'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})When you use both fields and omit in builder.get(), it first includes only the specified fields and then excludes those listed in omit in the response.
import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data, bigField, data.blocks'
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data,bigField,data.blocks'
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data,bigField,data.blocks'
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data,bigField,data.blocks'
}
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data,bigField,data.blocks'
}
})import { fetchOneEntry } from '@builder.io/sdk-react-native'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data,bigField,data.blocks'
}
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
omit: 'data,bigField,data.blocks'
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
omit: 'data,bigField,data.blocks'
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
omit: 'data, bigField, data.blocks'
}
})&omit=data.bigField,data.blocksFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&omit=data.bigField,data.blocks// replace model with your model name
builder.get('model', {
omit: 'data,bigField,data.blocks'
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
omit: 'data,bigField,data.blocks'
})The following video demonstrates installing the React SDK:
Builder applies targeting and personalization rules based on attributes like urlPath, device, and custom targeting attributes. To retrieve all the content entries regardless of targeting rules, set noTargeting to true in the options parameter.
For important information regarding targeting and scheduling and the Content API, see Scheduling behavior later in this document.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})The noTargeting option does not apply to Gen 2 frameworks.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})The noTargeting option does not apply to Gen 2 frameworks.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})The noTargeting option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTargeting option does not apply to Gen 2 frameworks.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})The noTargeting option does not apply to Gen 2 frameworks.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})The noTargeting option does not apply to Gen 2 frameworks.
The noTargeting option does not apply to Gen 2 frameworks.
The noTargeting option does not apply to Gen 2 frameworks.
The noTargeting option does not apply to Gen 2 frameworks.
The noTargeting option does not apply to Gen 2 frameworks.
The noTargeting option does not apply to Gen 2 frameworks.
The noTargeting option does not apply to Gen 2 frameworks.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})The noTargeting option does not apply to Gen 2 frameworks.
import { builder } from "@builder.io/angular";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
options: { noTargeting: true }
})Maximum number of results to return. The default is 30 and the maximum is 100.
import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
limit: 10,
// This will retrieve all content entries
options: { noTargeting: true }
})By default, Builder applies targeting rules based on attributes like urlPath, device, and custom targeting attributes. To retrieve all content entries, call builder.getAll() and set noTargeting to true in the options parameter.
import { fetchEntries } from '@builder.io/sdk-react'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
limit: 10,
options: { noTargeting: true }
})By default, Builder applies targeting rules based on attributes like urlPath, device, and custom targeting attributes. To retrieve all content entries, call builder.getAll() and set noTargeting to true in the options parameter.
import { fetchEntries } from '@builder.io/sdk-react'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
limit: 10,
options: { noTargeting: true }
})import { fetchEntries } from '@builder.io/sdk-react'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { fetchEntries } from '@builder.io/sdk-react'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
limit: 10,
options: { noTargeting: true }
})By default, Builder applies targeting rules based on attributes like urlPath, device, and custom targeting attributes. To retrieve all content entries, call builder.getAll() and set noTargeting to true in the options parameter.
import { fetchEntries } from '@builder.io/sdk-react'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
limit: 10,
options: { noTargeting: true }
})By default, Builder applies targeting rules based on attributes like urlPath, device, and custom targeting attributes. To retrieve all content entries, call builder.getAll() and set noTargeting to true in the options parameter.
import { fetchEntries } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { fetchEntries } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { fetchEntries } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { fetchEntries } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchEntries({
model: 'my-model-name',
limit: 10
})import { fetchEntries } from '@builder.io/sdk-react-native'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
limit: 10
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchEntries({
...,
limit: 10
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const allEntries = await builder.getAll('my-model-name', {
limit: 10,
options: { noTargeting: true }
})By default, Builder applies targeting rules based on attributes like urlPath, device, and custom targeting attributes. To retrieve all content entries, call builder.getAll() and set noTargeting to true in the options parameter.
import { fetchEntries } from '@builder.io/sdk-react'
// replace model with your model name
const entries = await fetchEntries({
model: 'my-model-name',
limit: 10
})&limit=10For example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&limit=10To fetch all content beyond the limit of 100, use limit and offset together by paginating results and making multiple API calls as follows:
const limit = 100;
let offset = 0;
const pages = await getResults({limit, offset});
while(pages.length === (limit + offset)) {
offset += pages.length;
pages.push( ... (await getResults({ limit, offset}));
}
return pages;// replace model with your model name
builder.get('model', {
limit: 10
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
limit: 10
})The following video demonstrates installing the React SDK:
Use to specify an offset for pagination of results. The default is 0.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react-native'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
offset: 10
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
offset: 10
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})import { fetchOneEntry } from '@builder.io/sdk-react'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
offset: 10
})&offset=10For example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&offset=10// replace model with your model name
builder.get('model', {
offset: 10
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
offset: 10
})The following video demonstrates installing the React SDK:
To fetch all content beyond the limit of 100, use limit and offset together by paginating results and making multiple API calls as follows:
const limit = 100;
let offset = 0;
const pages = await getResults({limit, offset});
while(pages.length === (limit + offset)) {
offset += pages.length;
pages.push( ... (await getResults({ limit, offset})));
}
return pages;For more detail, see this forum post and this forum post.
Include content of references in response.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The includeRefs option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
&includeRefs=trueFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&includeRefs=true// replace model with your model name
builder.get('model', {
includeRefs: true
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeRefs: true
})The following video demonstrates installing the React SDK:
Seconds to cache content. This sets the maximum age of the cache-control header response . Set value higher for better performance, and lower for content that changes frequently.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react-native'
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
cacheSeconds: 10
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
cacheSeconds: 10
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cacheSeconds: 10
})&cacheSeconds=1230For example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&cacheSeconds=1230// replace model with your model name
builder.get('model', {
cacheSeconds: 10
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
cacheSeconds: 10
})The following video demonstrates installing the React SDK:
Builder uses stale-while-revalidate caching at the CDN level, serving content from the edge cache while updates occur in the background for optimal performance.
The more frequently content is requested, the fresher it becomes. By default, Builder holds content in the stale cache for up to one day, but you can adjust this to a shorter duration if needed.
The minimum value for staleCacheSeconds is 1 hour, or 3600 seconds.
We recommend keeping this duration high unless you have low-traffic content that must update rapidly.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
staleCacheSeconds: 10
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
staleCacheSeconds: 10
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
staleCacheSeconds: 86400
})&staleCacheSeconds=86400For example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&staleCacheSeconds=86400// replace model with your model name
builder.get('model', {
staleCacheSeconds: 86400
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
staleCacheSeconds: 86400
})The following video demonstrates installing the React SDK:
Use the property to order results by setting the value to 1 for ascending and -1 for descending.
The key specifies the field to sort on. For example, sorting by createdDate with a value of 1 results in ascending order.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
sort: {
createdDate: 1
}
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
sort: {
createdDate: 1
}
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
sort: {
createdDate: 1
}
})&sort.createdDate=-1For example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&sort.createdDate=-1// replace model with your model name
builder.get('model', {
sort: {
createdDate: 1
}
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
sort: {
createdDate: 1
}
})The following video demonstrates installing the React SDK:
Exclude content entries that have passed their scheduled end date from the response. Use this when querying without targeting attributes to ensure expired entries are not returned.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})import { builder } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { builder } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { fetchOneEntry } from "@builder.io/sdk-svelte";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})import { builder } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
excludeExpired: true
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
includeUnpublished: true
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeExpired: true
},
})&excludeExpired=trueFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&excludeExpired=true// replace model with your model name
builder.get('model', {
excludeExpired: true
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeExpired: true
})The following video demonstrates installing the React SDK:
Exclude content entries whose scheduled start date has not yet been reached. Use this to ensure only currently active entries are returned when querying without targeting attributes.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})import { fetchOneEntry } from "@builder.io/sdk-svelte";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
excludeScheduled: true
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
includeUnpublished: true
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
excludeScheduled: true
},
})&excludeScheduled=trueFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&excludeScheduled=true// replace model with your model name
builder.get('model', {
excludeSchedule: true
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
excludeScheduled: true
})The following video demonstrates installing the React SDK:
Include content entries in a response that are still in draft mode and unarchived.
Important: You can restrict this option with a Space setting. See Restrict public API access below for details.
For important information regarding targeting and scheduling and the Content API, see Scheduling Behavior later in this document.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
includeUnpublished: true
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
includeUnpublished: true
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
options: {
includeUnpublished: true
},
})&includeUnpublished=trueFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&includeUnpublished=true// replace model with your model name
builder.get('model', {
includeUnpublished: true
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
includeUnpublished: true
})The following video demonstrates installing the React SDK:
Use published.$ne as a query filter to exclude entries based on their publish state. This uses the MongoDB-style "not equal", $ne, operator against the published field, which has three possible values: 'published', 'draft', and 'archived'.
The most common use is published.$ne=archived, which returns both published and draft entries while excluding archived ones.
import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
options: { noTargeting: true },
includeUnpublished: true,
query: {
published: { $ne: 'archived' }
}
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
options: { noTargeting: true },
includeUnpublished: true,
query: {
published: { $ne: 'archived' }
}
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
options: { noTargeting: true },
includeUnpublished: true,
query: {
published: { $ne: 'archived' }
}
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
options: { noTargeting: true },
includeUnpublished: true,
query: {
published: { $ne: 'archived' }
}
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
options: { noTargeting: true },
includeUnpublished: true,
query: {
published: { $ne: 'archived' }
}
})import { fetchOneEntry } from "@builder.io/sdk-svelte";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
query: {
published: { $ne: 'archived' }
}
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
includeUnpublished: true
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entries = await builder.getAll('my-model-name', {
options: { noTargeting: true },
includeUnpublished: true,
query: {
published: { $ne: 'archived' }
}
})import { fetchOneEntry } from "@builder.io/sdk-react";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
apiKey: YOUR_API_KEY,
options: {
includeUnpublished: true
},
query: {
published: { $ne: 'archived' }
},
})https://cdn.builder.io/api/v3/content/my-model-name
?apiKey=YOUR_API_KEY
&query.published.$ne=archived
&includeUnpublished=true// replace model with your model name
builder.get('my-model-name', {
query: {
published: { $ne: 'archived' }
}
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
query: {
published: { $ne: 'archived' }
}
})The following video demonstrates installing the React SDK:
Because published.$ne can expose draft content, it is subject to the same access restriction as includeUnpublished. If your space has Restrict Public API Key from Querying Unpublished Content enabled, this filter is blocked for the public API key and requires a Private API Key. See Restrict public API access to unpublished content for details.
By default, the Public API Key can query draft and archived content using includeUnpublished: true or published.$ne filters. If you want to prevent public access to unpublished content, you can enable the Restrict Public API Key from Querying Unpublished Content setting.
When enabled:
- The public API key cannot use
includeUnpublished: trueorpublished.$nefilters. - Only a Private API Key can query draft or archived content.
This setting is useful for preventing accidental exposure of draft or unfinished content in production environments.
To enable this setting, go to Settings → Advanced Settings → Advanced in your Space Settings.
Though the default is true, you can pass false to include Symbol JSON in the response. This is helpful if you want to render your page all at once such as in server-side rendering.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})true to ensure you get the most up-to-date data, bypassing the existing cache. This may be useful if you need to have The noTraverse option does not apply to Gen 2 frameworks. Use the enrich parameter instead.
&noTraverse=falseFor example, the whole URL could be:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&noTraverse=false// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
noTraverse: false
})The following video demonstrates installing the React SDK:
Set this to true to ensure you get the most up-to-date data. This may be particularly relevant for frequently changing content or situations where updated information is preferred.
This will bypass the default cache settings. Note that as a result response times will be significantly slower when using this option.
import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cachebust: true
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
options: {
cachebust: true
}
})builder.get('your-model', {
query: {
'data.myCustomProperty.$eq': 'sale'
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
options: {
cachebust: true
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cachebust: true
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
options: {
cachebust: true
}
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
options: {
cachebust: true
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cachebust: true
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
options: {
cachebust: true
}
})import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cachebust: true
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'model',
cachebust: true
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
// replace model with your model name
const entry = await fetchOneEntry({
model: 'model',
cachebust: true
})import { fetchOneEntry } from "@builder.io/sdk-vue";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cachebust: true
})import { fetchOneEntry } from "@builder.io/sdk-qwik";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cachebust: true
})import { fetchOneEntry } from "@builder.io/sdk-react-native";
// replace model with your model name
const entry = await fetchOneEntry({
model: 'my-model-name',
cachebust: true
})export class myComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
options: {
cachebust: true
}
});
this.content = entry;
}
}export const myComponentResolver: any => {
...
return fetchOneEntry({
...,
options: {
cachebust: true
}
...,
});
};import { builder } from "@builder.io/react";
// replace model with your model name
const entry = await builder.get('my-model-name', {
cachebust: true
})import { fetchOneEntry } from '@builder.io/sdk-react';
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
options: {
cachebust: true
}
})&cachebust=truehttps://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY&cachebust=true// replace model with your model name
builder.get('model', {
options: {
cachebust: true
}
})import { builder } from '@builder.io/sdk';
// replace model with your model name
const entry = await builder.get('my-model-name', {
cachebust: true
})Only set cachebust to true in the SDKs or APIs for build-time requests, such as when statically generating Pages, as response times will be slow when bypassing all caching. We do not recommend it for runtime requests — such as when serving Pages.
If intentionally choosing to bypass Builder's cache, it is highly recommended to provide your own cache layer to reduce the impact of potential service disruptions.
Request functionality can be modified in the following ways.
Use the fetch option to override the default behavior of the global fetch() function used in the API.
This is helpful for:
- Adding specific headers or handling authentication
- Using libraries like Axios
- Defining custom HTTP request logic, such as integrating custom agents
The fetch property expects a function with the same parameters as the global fetch() function. It takes url.href as the first parameter and optionally a configuration object as the second.
For more information, see fetch() parameters.
The fetch option does not apply to Gen 1 frameworks.
import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})The fetch option does not apply to Gen 1 frameworks.
import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})The fetch option does not apply to Gen 1 frameworks.
import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})The fetch option does not apply to Gen 1 frameworks.
import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})The fetch option does not apply to Gen 1 frameworks.
import { fetchOneEntry } from '@builder.io/sdk-svelte';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})import { fetchOneEntry } from '@builder.io/sdk-svelte';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})import { fetchOneEntry } from '@builder.io/sdk-vue';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})import { fetchOneEntry } from '@builder.io/sdk-vue';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})import { fetchOneEntry } from '@builder.io/sdk-qwik';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})In some cases, you might need to override the global fetch() function to customize API calls, such as implementing caching or using custom HTTP agents. The following example demonstrates how to provide a custom fetch() function that integrates custom agents:
import { fetchOneEntry } from '@builder.io/sdk-angular';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
export const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
export class MyComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
fetch: customFetch
});
this.content = entry;
}
}To improve efficiency, this next example customizes fetch() to cache API responses, reducing redundant network requests. By leveraging Angular’s HttpClient, fetch() makes sure that responses are stored and reused instead of making duplicate API calls.
This approach is particularly useful in scenarios where the same content needs to be retrieved multiple times, such as during hydration.
// other imports
import { inject } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
export class MyComponent{
content: any;
private http = inject(HttpClient);
customFetch = async (url: string, options: RequestInit) => {
// Make the request using Angular's HttpClient, convert Observable -> Promise
return firstValueFrom(
this.http.request<any>(options.method || 'GET', url, {
body: options.body,
headers: options.headers as any,
// spread things such as credentials
...options,
observe: 'response',
responseType: 'json',
})
).then((response: HttpResponse<any>) => {
return {
ok: response.status >= 200 && response.status < 300,
status: response.status,
json: () => Promise.resolve(response.body),
};
});
};
async ngOnInit() {
const entry = await fetchOneEntry({
fetch: this.customFetch
});
this.content = entry;
}
}To customize how API calls are handled, you can override the global fetch() function by using custom HTTP agents. This means better control over network connections, such as keeping persistent connections alive to improve efficiency. The following example demonstrates how to integrate custom HTTP agents when making requests:
import { fetchOneEntry } from '@builder.io/sdk-angular';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
export const MyComponentResolver = (): any => {
...
return fetchOneEntry({
...,
fetch: customFetch
...,
});
};In server-side rendering (SSR) environments, it’s important to optimize API calls by caching responses. This prevents redundant requests, improves performance, and ensures content persists during hydration.
The following approach introduces a customFetch() function inside a service (BuilderService), which integrates Angular’s HttpClient to store and reuse API responses.
First, define the custom fetch() function in a new file calledBuilderService.ts:
// app/BuilderService.ts
import { HttpClient, HttpResponse } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { firstValueFrom } from 'rxjs';
@Injectable({ providedIn: 'root' })
// Define customFetch as a local async function
export class BuilderService {
private http = inject(HttpClient);
customFetch = async <T>(url: string, options: RequestInit) => {
// Make the request using Angular's HttpClient, converting Observable -> Promise
return firstValueFrom(
this.http.request<T>(options.method || 'GET', url, {
body: options.body,
headers: options.headers as any,
// Spread other options such as credentials
...options,
observe: 'response',
responseType: 'json',
})
).then((response: HttpResponse<any>) => {
return {
ok: response.status >= 200 && response.status < 300,
status: response.status,
json: () => Promise.resolve(response.body),
};
});
};
}In the resolver, inject BuilderService into the resolver and assign customFetch to the fetch option in fetchOneEntry().
// app/custom-components/myComponentResolver.ts
// other imports
import { inject } from '@angular/core';
import { BuilderService } from './builder-service';
import { fetchOneEntry } from '@builder.io/sdk-angular';
export const MyComponentResolver = (): any => {
const builderService = inject(BuilderService);
await fetchOneEntry({
apiKey: /* YOUR PUBLIC API KEY */,
model: /* YOUR MODEL NAME */,
fetch: builderService.customFetch, /* overrides default global `fetch()` */
/* Other fields */
});
};Finally, make sure the custom fetch function is properly configured inapp.config.ts:
// other imports coming from --standalone
import { provideHttpClient, withFetch } from '@angular/common/http';
export const appConfig: ApplicationConfig = {
providers: [
...
provideHttpClient(withFetch()),
],
};
The fetch option does not apply to Gen 1 frameworks.
import { fetchOneEntry } from '@builder.io/sdk-react';
import http from 'node:http';
import https from 'node:https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
// Custom fetch implementation
const customFetch = (url:String, init:Object): Promise<any> => {
const agent = url.startsWith('https') ? httpsAgent : httpAgent;
return fetch(url, { ...init, agent });
};
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: customFetch
})The fetch option does not apply to Gen 1 frameworks.
Specifies additional RequestInit options to configure the overridden fetch request, including:
headersfor custom request headerscredentialsto control authenticationkeepalivefor background requests and sending analyticsmethodto define the HTTP method
Keep in mind that fetchOptions can be used regardless of whether or not fetch was modified, and is usable in both Gen 1 and Gen 2 SDKs.
import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions = MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions = MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: 'https://www.mywebsite.com',
fetchOptions: MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
export class MyComponent{
content: any;
async ngOnInit() {
const entry = await fetchOneEntry({
...,
fetchOptions: MyFetchOptions
});
this.content = entry;
}
}export const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
export const MyComponentResolver: any => {
...
return fetchOneEntry({
...,
fetch: /* `myCustomFetchFn` overrides default global `fetch()` */
fetchOptions: MyFetchOptions
...,
});
};import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions = MyFetchOptions
})import { fetchOneEntry } from '@builder.io/sdk-react';
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await fetchOneEntry({
model: /* ENTER YOUR MODEL NAME */,
fetch: /* myCustomFetchFn overrides default global `fetch()` */,
fetchOptions: MyFetchOptions
})import { builder } from "@builder.io/react";
const MyFetchOptions: RequestInit = {
method: "GET",
cache: "no-cache",
keepalive: true // Ensures the connection remains open for reuse
}
// replace model with your model name
const entry = await builder.get('my-model-name', {
fetchOptions: MyFetchOptions
})Content API v3 is currently the default. Learn more in Content API Versions.
Builder content scheduling using startDate and endDate is only checked if all of the following conditions are met:
userAttributesare included in the requestnoTargetingis not passed or is set tofalse
If these conditions are met, then Builder includes a content entry if the current time falls between the entry's startDate and endDate.
By default, Builder uses the server's current time. You can override this by passing a date value in userAttributes.date.
If a reference's schedule is invalid, it is skipped and not included in the response.
If you're debugging missing content in API responses, make sure userAttributes are included and that you are not disabling targeting or scheduling unintentionally.
To experiment with the Content API, you can use the Builder API Explorer, which offers a way for you to compose queries in your own Builder Space. This way, you can confirm that your queries are correct before editing your code base.