多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
6.0 KiB

"use strict";(self.webpackChunknoco_docs=self.webpackChunknoco_docs||[]).push([[6141],{3905:(e,t,r)=>{r.d(t,{Zo:()=>c,kt:()=>v});var n=r(67294);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var p=n.createContext({}),s=function(e){var t=n.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},c=function(e){var t=s(e.components);return n.createElement(p.Provider,{value:t},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},m=n.forwardRef((function(e,t){var r=e.components,o=e.mdxType,a=e.originalType,p=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),d=s(r),m=o,v=d["".concat(p,".").concat(m)]||d[m]||u[m]||a;return r?n.createElement(v,i(i({ref:t},c),{},{components:r})):n.createElement(v,i({ref:t},c))}));function v(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=r.length,i=new Array(a);i[0]=m;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l[d]="string"==typeof e?e:o,i[1]=l;for(var s=2;s<a;s++)i[s]=r[s];return n.createElement.apply(null,i)}return n.createElement.apply(null,r)}m.displayName="MDXCreateElement"},58640:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>p,contentTitle:()=>i,default:()=>u,frontMatter:()=>a,metadata:()=>l,toc:()=>s});var n=r(87462),o=(r(67294),r(3905));const a={title:"NocoDB SDK",description:"NocoDB SDK Overview"},i=void 0,l={unversionedId:"developer-resources/sdk",id:"version-0.109.7/developer-resources/sdk",title:"NocoDB SDK",description:"NocoDB SDK Overview",source:"@site/versioned_docs/version-0.109.7/040.developer-resources/030.sdk.md",sourceDirName:"040.developer-resources",slug:"/developer-resources/sdk",permalink:"/0.109.7/developer-resources/sdk",draft:!1,editUrl:"https://github.com/nocodb/nocodb/tree/develop/packages/noco-docs/docs/versioned_docs/version-0.109.7/040.developer-resources/030.sdk.md",tags:[],version:"0.109.7",sidebarPosition:30,frontMatter:{title:"NocoDB SDK",description:"NocoDB SDK Overview"},sidebar:"tutorialSidebar",previous:{title:"REST APIs",permalink:"/0.109.7/developer-resources/rest-apis"},next:{title:"Webhooks",permalink:"/0.109.7/developer-resources/webhooks"}},p={},s=[{value:"SDK For Javascript",id:"sdk-for-javascript",level:2},{value:"Install nocodb-sdk",id:"install-nocodb-sdk",level:3},{value:"Import Api",id:"import-api",level:3},{value:"Configure Api",id:"configure-api",level:3},{value:"Example: Auth Token",id:"example-auth-token",level:4},{value:"Example: API Token",id:"example-api-token",level:4},{value:"Call Functions",id:"call-functions",level:3},{value:"Example: Calling API - /api/v1/db/meta/projects/{projectId}/tables",id:"example-calling-api---apiv1dbmetaprojectsprojectidtables",level:4}],c={toc:s},d="wrapper";function u(e){let{components:t,...r}=e;return(0,o.kt)(d,(0,n.Z)({},c,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("p",null,"We provide SDK for users to integrate with their applications. Currently only SDK for Javascript is supported."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"The NocoDB SDK requires authorization token. If you haven't created one, please check out ",(0,o.kt)("a",{href:"/0.109.7/developer-resources/accessing-apis",target:"_blank"},"Accessing APIs")," for details.")),(0,o.kt)("h2",{id:"sdk-for-javascript"},"SDK For Javascript"),(0,o.kt)("h3",{id:"install-nocodb-sdk"},"Install nocodb-sdk"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash"},"npm i nocodb-sdk\n")),(0,o.kt)("h3",{id:"import-api"},"Import Api"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-js"},"import { Api } from 'nocodb-sdk'\n")),(0,o.kt)("h3",{id:"configure-api"},"Configure Api"),(0,o.kt)("p",null,"The Api can be authorizated by either Auth Token or API Token."),(0,o.kt)("h4",{id:"example-auth-token"},"Example: Auth Token"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-js"},"const api = new Api({\n baseURL: 'https://<HOST>:<PORT>',\n headers: {\n 'xc-auth': '<AUTH_TOKEN>'\n }\n})\n")),(0,o.kt)("h4",{id:"example-api-token"},"Example: API Token"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-js"},"const api = new Api({\n baseURL: 'https://<HOST>:<PORT>',\n headers: {\n 'xc-token': '<API_TOKEN>'\n }\n})\n")),(0,o.kt)("h3",{id:"call-functions"},"Call Functions"),(0,o.kt)("p",null,"Once you have configured ",(0,o.kt)("inlineCode",{parentName:"p"},"api"),", you can call different types of APIs by ",(0,o.kt)("inlineCode",{parentName:"p"},"api.<Tag>.<FunctionName>"),". "),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"For Tag and FunctionName, please check out the API table ",(0,o.kt)("a",{href:"/0.109.7/developer-resources/rest-apis",target:"_blank"},"here"),".")),(0,o.kt)("h4",{id:"example-calling-api---apiv1dbmetaprojectsprojectidtables"},"Example: Calling API - /api/v1/db/meta/projects/{projectId}/tables"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-js"},"await api.dbTable.create(params)\n")))}u.isMDXComponent=!0}}]);