Gathering detailed insights and metrics for @commercetools/sdk-client-v2
Gathering detailed insights and metrics for @commercetools/sdk-client-v2
npm install @commercetools/sdk-client-v2
Typescript
Module System
Min. Node Version
Node Version
NPM Version
@commercetools/ts-client@3.0.3
Published on 29 Jan 2025
@commercetools/ts-client@3.0.2
Published on 24 Jan 2025
@commercetools/history-sdk@5.1.0
Published on 15 Jan 2025
@commercetools/platform-sdk@8.1.0
Published on 15 Jan 2025
@commercetools/ts-sdk-apm@3.1.0
Published on 15 Jan 2025
@commercetools/ts-client@3.0.1
Published on 15 Jan 2025
TypeScript (99.83%)
JavaScript (0.13%)
Makefile (0.04%)
Shell (0.01%)
Total Downloads
8,694,325
Last Day
18,830
Last Week
79,371
Last Month
322,112
Last Year
4,086,708
53 Stars
912 Commits
26 Forks
44 Watching
26 Branches
340 Contributors
Latest Version
3.0.0
Package Id
@commercetools/sdk-client-v2@3.0.0
Unpacked Size
320.85 kB
Size
78.47 kB
File Count
40
NPM Version
10.8.2
Node Version
20.18.0
Publised On
08 Jan 2025
Cumulative downloads
Total Downloads
Last day
7.3%
18,830
Compared to previous day
Last week
-6.8%
79,371
Compared to previous week
Last month
8.6%
322,112
Compared to previous month
Last year
21.7%
4,086,708
Compared to previous year
1
5
1<script src="https://unpkg.com/@commercetools/sdk-client-v2@latest/dist/commercetools-sdk-client-v2.umd.js"></script> 2<script src="https://unpkg.com/@commercetools/platform-sdk@latest/dist/commercetools-platform-sdk.umd.js"></script>
1<script> 2 // global: @commercetools/sdk-client-v2 3 // global: @commercetools/platform-sdk 4 ;(function () { 5 // We can now access the sdk-client-v2 and platform-sdk object as: 6 // const { ClientBuilder } = this['@commercetools/sdk-client-v2'] 7 // const { createApiBuilderFromCtpClient } = this['@commercetools/platform-sdk'] 8 // or 9 // const { ClientBuilder } = window['@commercetools/sdk-client-v2'] 10 // const { createApiBuilderFromCtpClient } = window['@commercetools/platform-sdk'] 11 })() 12</script>
See full usage example here
1npm install --save @commercetools/sdk-client-v2 2npm install --save @commercetools/platform-sdk
1const { 2 ClientBuilder, 3 createAuthForClientCredentialsFlow, 4 createHttpClient, 5} = require('@commercetools/sdk-client-v2') 6const { createApiBuilderFromCtpClient } = require('@commercetools/platform-sdk') 7 8const projectKey = 'mc-project-key' 9const authMiddlewareOptions = { 10 host: 'https://auth.europe-west1.gcp.commercetools.com', 11 projectKey, 12 credentials: { 13 clientId: 'mc-client-id', 14 clientSecret: 'mc-client-secrets', 15 }, 16 oauthUri: '/oauth/token', // - optional: custom oauthUri 17 scopes: [`manage_project:${projectKey}`], 18 fetch, 19} 20 21const httpMiddlewareOptions = { 22 host: 'https://api.europe-west1.gcp.commercetools.com', 23 fetch, 24} 25 26const client = new ClientBuilder() 27 .withProjectKey(projectKey) 28 .withMiddleware(createAuthForClientCredentialsFlow(authMiddlewareOptions)) 29 .withMiddleware(createHttpClient(httpMiddlewareOptions)) 30 .withUserAgentMiddleware() 31 .build() 32 33// or 34const client = new ClientBuilder() 35 .withProjectKey(projectKey) 36 .withClientCredentialsFlow(authMiddlewareOptions) 37 .withHttpMiddleware(httpMiddlewareOptions) 38 .withUserAgentMiddleware() 39 .build() 40 41const apiRoot = createApiBuilderFromCtpClient(client) 42 43// calling the Composable Commerce functions 44// get project details 45apiRoot 46 .withProjectKey({ 47 projectKey, 48 }) 49 .get() 50 .execute() 51 .then((x) => { 52 /*...*/ 53 }) 54 55// create a productType 56apiRoot 57 .withProjectKey({ projectKey }) 58 .productTypes() 59 .post({ 60 body: { name: 'product-type-name', description: 'some description' }, 61 }) 62 .execute() 63 .then((x) => { 64 /*...*/ 65 }) 66 67// create a product 68apiRoot 69 .withProjectKey({ projectKey }) 70 .products() 71 .post({ 72 body: { 73 name: { en: 'our-great-product-name' }, 74 productType: { 75 typeId: 'product-type', 76 id: 'some-product-type-id', 77 }, 78 slug: { en: 'some-slug' }, 79 }, 80 }) 81 .execute() 82 .then((x) => { 83 /*...*/ 84 }) 85 86// ----------------------------------------------------------------------- 87// The sdk-client-v2 also has support for the old syntax 88import { 89 createClient, 90 createHttpClient, 91 createAuthForClientCredentialsFlow, 92} from '@commercetools/sdk-client-v2' 93import { createApiBuilderFromCtpClient } from '@commercetools/platform-sdk' 94 95const projectKey = 'some_project_key' 96 97const authMiddleware = createAuthForClientCredentialsFlow({ 98 host: 'https://auth.europe-west1.gcp.commercetools.com', 99 projectKey, 100 credentials: { 101 clientId: 'some_id', 102 clientSecret: 'some_secret', 103 }, 104 fetch, 105}) 106 107const httpMiddleware = createHttpClient({ 108 host: 'https://api.europe-west1.gcp.commercetools.com', 109 fetch, 110}) 111 112const ctpClient = createClient({ 113 middlewares: [authMiddleware, httpMiddleware], 114}) 115 116const apiRoot = createApiBuilderFromCtpClient(ctpClient) 117 118apiRoot 119 .withProjectKey({ 120 projectKey, 121 }) 122 .get() 123 .execute() 124 .then((x) => { 125 /*...*/ 126 }) 127 128apiRoot 129 .withProjectKey({ projectKey }) 130 .productTypes() 131 .post({ 132 body: { name: 'product-type-name', description: 'some description' }, 133 }) 134 .execute() 135 .then((x) => { 136 /*...*/ 137 }) 138 139apiRoot 140 .withProjectKey({ projectKey }) 141 .products() 142 .post({ 143 body: { 144 name: { en: 'our-great-product-name' }, 145 productType: { 146 typeId: 'product-type', 147 id: 'some-product-type-id', 148 }, 149 slug: { en: 'some-slug' }, 150 }, 151 }) 152 .execute() 153 .then((x) => { 154 /*...*/ 155 })
See full usage example here
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
Found 8/12 approved changesets -- score normalized to 6
Reason
branch protection is not maximal on development and all release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More