@getneurotic/api v1.0.5
Neurotic API Client 🤓💻
Welcome to the Neurotic API Client repository, a place where you can interact with the Neurotic API in a more efficient and nerdy way! 🚀
Description 📝
A client module designed to make your interaction with the Neurotic API smoother and more efficient. Dive into the world of Neurotic API with this handy client! 🌎
Installation 🛠️
Get started with the Neurotic API Client by installing it in your project. You can use either of the following commands based on your package manager preference:
Using yarn:
yarn add -D @getneurotic/api
Using npm:
npm install -D @getneurotic/api
Usage 📚
Before you dive into coding, make sure to set up your environment variables. Create a .env
file in your root directory and add the following lines:
NEUROTIC_ENDPOINT=your_endpoint_url
NEUROTIC_KEY=your_api_key
Now, you are all set to use the API client in your project! Here's a snippet to get you started:
import api from '@getneurotic/api';
// Default options for API methods
const defaultOptions = {
is_active: true,
limit: null,
order_by: ['created_at', 'desc'],
skip: null,
};
// Fetch a record by its ID
api.get('record_id').then(response => {
console.log(response.data);
});
// Create a new record with default options
api.create('recordType', {data: 'your_data_here'}, { is_active: true }).then(response => {
console.log(response.data);
});
// Delete a record by its ID
api.delete('record_id').then(response => {
console.log(response.data);
});
// Find records based on type and filter with various options
// Example 1: Finding records of a single type with a simple filter
api.find('recordType1', [
['field1', '=', 'value1'],
['field2', '<', 'value2'],
], defaultOptions).then(response => {
console.log(response.data);
});
// Example 2: Finding records of multiple types with a complex filter and custom options
api.find(
['recordType1', 'recordType2'],
[
['field1', '=', 'value1'],
['field2', '<', 'value2'],
],
{ skip: 10, limit: 15, order_by: ['field1', 'asc'] },
).then(response => {
console.log(response.data);
});
// Update a record by its ID with default options
api.update('record_id', { field1: 'value1' }, { is_active: true }).then(response => {
console.log(response.data);
});
API Methods 🤖
The client offers a variety of methods to interact with the API, including:
get(id)
: Retrieve a record by its ID. Returns a promise that resolves with the retrieved record.create(recordType, data, options)
: Create a new record. Returns a promise that resolves with the created record.delete(id)
: Delete a record by its ID. Returns a promise that resolves when the record is deleted.find(recordType, filter, options)
: Find records based on type and filter. The filter parameter is an array of filter criteria. Returns a promise that resolves with the found records.update(id, data, options)
: Update a record by its ID. Returns a promise that resolves with the updated record.
Contributing 🤝
We welcome pull requests! If you are thinking about major changes, please open an issue first to discuss what you would like to change. Let's collaborate and make this project even better! 💪
License 📄
This project is licensed under the MIT License. Feel free to use it and build upon it!
Programming Language 💻
The project is written in 100% JavaScript, making it a great choice for JS enthusiasts!