![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@carto/api-client
Advanced tools
Client library for CARTO APIs and framework-agnostic CARTO + deck.gl applications
@carto/api-client
JavaScript (and TypeScript) client library for CARTO APIs and framework-agnostic CARTO + deck.gl applications.
Includes:
Install @carto/api-client
:
npm install --save @carto/api-client
Import vectorTableSource
, vectorQuerySource
, and other data source functions
from the @carto/api-client
package. These are drop-in replacements for the equivalent functions from the @deck.gl/carto
package, and the same data source may be used with any number of layers or widgets. Tileset sources are not yet supported.
import { vectorTableSource } from '@carto/api-client';
const data = await vectorTableSource({
accessToken: '••••',
connectionName: 'carto_dw',
tableName: 'carto-demo-data.demo_tables.retail_stores'
});
// → {name: string; value: number}[]
const categories = await data.widgetSource.getCategories({
column: 'store_type',
operation: 'count',
});
// → {value: number}
const formula = await data.widgetSource.getFormula({operation: 'count'});
// → {totalCount: number; rows: Record<string, number | string>[]}
const table = await data.widgetSource.getTable({
columns: ['a', 'b', 'c'],
sortBy: ['a'],
rowsPerPage: 20
});
...
To filter the widget source by a non-geospatial column, pass a filters
property to the source factory function.
import {vectorTableSource} from '@carto/api-client';
const data = await vectorTableSource({
accessToken: '••••',
connectionName: 'carto_dw',
tableName: 'carto-demo-data.demo_tables.retail_stores',
filters: {
store_type: {owner: 'widget-id', values: ['retail']},
},
});
By default, filters affect all layers and widgets using a given data source. To
exclude a particular widget from the filter, pass a filterOwner
parameter
matching the filters from which it should be excluded. In some cases, a widget's
results should not be affected by a filter that the widget itself created.
// → {name: string; value: number}[]
const categories = await data.widgetSource.getCategories({
filterOwner: 'widget-id',
column: 'store_type',
operation: 'count',
});
To filter the widget source to a spatial region, pass a spatialFilter
parameter (GeoJSON Polygon or MultiPolygon geometry) to any data fetching function.
// → {name: string; value: number}[]
const categories = await data.widgetSource.getCategories({
column: 'store_type',
operation: 'count',
spatialFilter: {
type: "Polygon"
coordinates: [
[
[-74.0562, 40.8331],
[-74.0562, 40.6933],
[-73.8734, 40.6933],
[-73.8734, 40.8331],
[-74.0562, 40.8331]
]
],
}
});
To create a spatial filter from the current deck.gl viewState
:
import {WebMercatorViewport} from '@deck.gl/core';
import {createViewportSpatialFilter} from '@carto/api-client';
const viewport = new WebMercatorViewport(viewState);
const spatialFilter = createViewportSpatialFilter(viewport.getBounds());
Factory functions, like vectorTableSource
, support both layers
and widgets. While reusing the same sources has advantages, including simplicity, it's important to understand which columns are fetched, which
depends on the source type.
columns
parameter. Widgets fetch only the columns they need, and are unaffected by
the columns
parameter.columns
parameter. Widgets fetch only the subset they need, and are unaffected by the columns
parameter.Package versioning follows Semantic Versioning 2.0.0.
Provided as open source under MIT License.
FAQs
Client library for CARTO APIs and framework-agnostic CARTO + deck.gl applications
The npm package @carto/api-client receives a total of 0 weekly downloads. As such, @carto/api-client popularity was classified as not popular.
We found that @carto/api-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.