@cords/sdk
v0.1.9
Published
The Cords API SDK provides a convenient way to interact with the Cords API, offering a set of methods to perform various operations such as searching, fetching related resources, and retrieving individual resources. This SDK is designed to simplify the pr
Downloads
34
Readme
Cords API SDK
The Cords API SDK provides a convenient way to interact with the Cords API, offering a set of methods to perform various operations such as searching, fetching related resources, and retrieving individual resources. This SDK is designed to simplify the process of integrating Cords API functionalities into your applications.
Installation
You can install the SDK using npm or any other package manager:
npm install @cords/sdkUsage
Initialization
First, import the CordsAPI function and initialize it with your API key:
import { CordsAPI } from "@cords/sdk";
const cords = CordsAPI({ apiKey: "your_api_key_here" });Searching
To perform a search, use the search method. You can pass a query string and optional search options:
const searchResults = await cords.search("query", {
lat: 40.7128,
lng: -74.006,
page: 1,
pageSize: 10,
distance: 10,
partner: {
"211": true,
mentor: true,
},
delivery: {
local: true,
},
});Fetching Related Resources
To fetch resources related to a specific resource, use the related method:
const relatedResources = await cords.related("resource_id");Retrieving a Single Resource
To retrieve a single resource by its ID, use the resource method:
const resource = await cords.resource("resource_id");Fetching Multiple Resources
To fetch multiple resources by their IDs, use the resourceList method:
const resources = await cords.resourceList(["resource_id_1", "resource_id_2"]);Formatting Service Address
The SDK also includes a utility function to format service addresses:
import { formatServiceAddress } from "@cords/sdk";
const formattedAddress = formatServiceAddress(resource.data.address);