Examples
This topic describes how to download and run OCI SDK for TypeScript and JavaScript usage examples.
GitHub
Examples of SDK usage can be found on GitHub, including:
The examples are also in the downloadable .zip file for the SDK. Examples for older versions of the SDK are in the downloadable .zip for the specific version, available on GitHub.
If you'd like to see another example not already covered, file a GitHub issue.
SDK Reference
In addition to the examples found on GitHub, the SDK for TypeScript and JavaScript API reference contains code examples that you can copy and modify to run in your own environment.
Running Examples
Note
If you're using Windows, you'll need to install Git Bash for Windows before running the following commands.
If you're using Windows, you'll need to install Git Bash for Windows before running the following commands.
- Git clone the SDK for TypeScript and JavaScript
git clone https://github.com/oracle/oci-typescript-sdk.git
- Change to the directory where you installed the
oci-typescript-sdk
repository. - Run
npm install
- Run
npm run build
- If you do not have typescript globally installed, run:
npm install -g typescript@4.1.3.
Note
We've tested and support TypeScript version 4.1.3 with the OCI SDK for TypeScript and JavaScript. We cannot guarantee full support for other versions of TypeScript. - You can optionally install ts-node globally to make it easier to run
examples:
npm install -g ts-node
- Create your configuration file in your home directory. See SDK and CLI Configuration File for more information.
- Change directory into the TypeScript example folder to run TypeScript examples. For
example:
cd ./oci-typescript-sdk/examples/typescript/
- Run any of the examples. For example, if you're running ts-node:
ts-node "./identity.ts"
If you're not running ts-node:tsc ./identity.ts node ./identity.js
- Some examples are available in JavaScript. They are located in the
oci-typescript-sdk/examples/javascript
folder. To run the JavaScript equivalent of the above example:node "./identity.js"