Skip to main content

Connector API

All URIs are relative to http://localhost:1000

MethodHTTP requestDescription
connectPOST /connect/connect [POST]
intentionPOST /{application}/intention/{application}/intention [POST]
onboardedPOST /{application}/onboarded/onboarded [POST]
reactPOST /{application}/reaction/{application}/reaction [POST]
suggestPOST /{application}/suggestion/{application}/suggestion [POST]
trackPOST /{application}/track/{application}/track [POST]

connect

Context connect()

Abstracts a bootup/connection for a specific context.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.ConnectorApi(configuration)

const body: Pieces.ConnectRequest = {
// SeededConnectorConnection | (optional)
seededConnectorConnection: ,
};

apiInstance.connect(body).then((data: Context) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
seededConnectorConnectionSeededConnectorConnection

Return type

Context

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK-
400Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration.-

intention

string intention()

Allows you to send a SeededAsset for future comparison.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.ConnectorApi(configuration)

const body: Pieces.IntentionRequest = {
// string
application: application_example,
// SeededConnectorAsset (optional)
seededConnectorAsset: ,
};

apiInstance.intention(body).then((data: string) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
seededConnectorAssetSeededConnectorAsset
application[string]defaults to undefined

Return type

string

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK-
400Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration.-
401Unauthorized, you will get this in the case that you are trying to ping Pieces_OS but havnt connected yet."/connect was not called for your application."-
500Internal Server Error:-

onboarded

string onboarded()

A central endpoint to manage updates to the onboarding process.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.ConnectorApi(configuration)

const body: Pieces.OnboardedRequest = {
// string | This is a uuid that represents an application
application: application_example,
// boolean | Whether or not that application has been onboarded. (optional)
body: true,
};

apiInstance.onboarded(body).then((data: string) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
bodybooleanWhether or not that application has been onboarded.
application[string]This is a uuid that represents an applicationdefaults to undefined

Return type

string

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK, This will just return a string of "OK".-
400Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration.-
401Unauthorized, you will get this in the case that you are trying to ping Pieces_OS but havnt connected yet."/connect was not called for your application."-

react

string react()

This will respond to the output generated by the /suggest endpoint.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.ConnectorApi(configuration)

const body: Pieces.ReactRequest = {
// string
application: application_example,
// Reaction | ** This body will need to be modified. (optional)
reaction: ,
};

apiInstance.react(body).then((data: string) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
reactionReaction** This body will need to be modified.
application[string]defaults to undefined

Return type

string

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200This string will either (1) be a string of the AssetUid or (2) will be a generic string of 'OK' if the asset was not saved and 'OK' if the result was just used to send information about the a suggested reuse.-
400Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration.-
401Unauthorized, you will get this in the case that you are trying to ping Pieces_OS but havnt connected yet."/connect was not called for your application."-

suggest

Suggestion suggest()

Invoked whenever a code snippet is copied from an integration. For instance, if a JetBrains user copies code, this endpoint can be called to assess whether to suggest reusing a piece (if reuse is true, the endpoint provides assets that the user may consider using), saving the code snippet, or taking no action. **Note: This endpoint could potentially accept a SeededFormat for the request body if required.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.ConnectorApi(configuration)

const body: Pieces.SuggestRequest = {
// string
application: application_example,
// SeededConnectorCreation | This is the Snippet that we will compare to all the saved assets to determine what we want to do with it! (optional)
seededConnectorCreation: ,
};

apiInstance.suggest(body).then((data: Suggestion) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
seededConnectorCreationSeededConnectorCreationThis is the Snippet that we will compare to all the saved assets to determine what we want to do with it!
application[string]defaults to undefined

Return type

Suggestion

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK-
400Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration.-
401Unauthorized, you will get this in the case that you are trying to ping Pieces_OS but havnt connected yet."/connect was not called for your application."-

track

string track()

Abstracts the process of packaging segments on a per-context basis.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.ConnectorApi(configuration)

const body: Pieces.TrackRequest = {
// string | This is a uuid that represents an application
application: application_example,
// SeededConnectorTracking | The body is able to take in several properties (optional)
seededConnectorTracking: ,
};

apiInstance.track(body).then((data: string) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
seededConnectorTrackingSeededConnectorTrackingThe body is able to take in several properties
application[string]This is a uuid that represents an applicationdefaults to undefined

Return type

string

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK, This will jsut return a string of "OK".-
400Bad Request, Application Failed to connect, Please ensure this is a valid integration. This happens in the case a developer provides and incorrect {application} (applicationId) within the route that doest match a preregisterd integration.-
401Unauthorized, you will get this in the case that you are trying to ping Pieces_OS but havnt connected yet."/connect was not called for your application."-