A library that makes requests to Bitrix API much easier.
Using npm:
$ npm install bitrix-gds
Using yarn:
$ yarn add bitrix-gds
import Bitrix24 from 'bitrix-gds'
const bitrix24 = new Bitrix24(
`https://YOUR_DOMAIN.bitrix24.{ru|com|de}/rest/{USER_ID}/{WEBHOOK_TOKEN}`
)
Create a inbound webhook in your bitrix.
Copy and Paste the endpoint given by bitrix, as a param in Bitrix24 new instance.
const { result } = await bitrix.deals.add({
fields: {
TITLE: 'John Doe'
}
})
- fields - An object that specifies the parameter for a new deal (Not required)
- params - Set of parameters. REGISTER_SONET_EVENT (Not required)
const { result } = await bitrix.deals.get({ id: '00' })
- id - deal ID.
const { result } = await bitrix.deals.delete({ id: '00' })
- id - deal ID.
const { result } = await bitrix.deals.fields()
const { result } = await bitrix.deals.list({
filter: {
STAGE_ID: '00'
},
select: ['*']
})
- filter - Object of fields and values to filter deals. (Not required)
- select - Array of fields IDs that will return with the request response (Not required)
- order - Order the response 'ASC' or 'DESC' by fields. (Not required)
- start - Start of the request. (Not required)
const { result } = await bitrix.deals.get({
id: '00',
fields: {
TITLE: 'John Doe'
}
})
- fields - Object of fields to be update.
- id - Deal ID.
const { result } = await bitrix.contacts.add({
fields: {
NAME: 'John Doe'
}
})
- fields - An object that specifies the parameter for a new contact (Not required)
- params - Set of parameters. REGISTER_SONET_EVENT (Not required)
const { result } = await bitrix.contacts.get({ id: '00' })
- id - Contact ID.
const { result } = await bitrix.contacts.delete({ id: '00' })
- id - Contact ID.
const { result } = await bitrix.contacts.fields()
const { result } = await bitrix.contacts.list({
filter: {
NAME: 'John Doe'
},
select: ['*']
})
- filter - Object of fields and values to filter deals. (Not required)
- select - Array of fields IDs that will return with the request response (Not required)
- order - Order the response 'ASC' or 'DESC' by fields. (Not required)
- start - Start of the request. (Not required)
const { result } = await bitrix.contacts.get({
id: '00',
fields: {
NAME: 'John Doe'
}
})
- fields - Object of fields to be update.
- id - Contact ID.
const { result } = await bitrix.batch({
req_1: {
method: 'crm.deal.add',
params: {
fields: {
TITLE: 'new deal'
}
}
},
req_2: {
method: 'crm.contact.list',
params: {
select: ['*']
}
}
})