@sapmentors/cds-scp-api
A Node module for CAP that calls an external API through a destination instead of a hardcoded endpoint, taking its address, credentials and on-premise tunnel from the SAP Destination and Connectivity services.
Calling an API outside the application means holding its address, its credentials and, for an on-premise system, a tunnel. This module takes all three from the SAP Destination serviceSAP Destination serviceNamed, credentialed addresses of other systems, resolved at runtime — so an application holds no URL and no secret of its own, and the same code reaches a different system in every landscape.sap official, btp and the SAP Connectivity serviceSAP Connectivity serviceThe proxy through which a cloud application reaches an on-premise system behind a Cloud Connector — HTTP, RFC and raw sockets — without that system being exposed.sap official, btp instead: cdsapi.connect.to("ES5") resolves a destination by name, and service.run({ url: "/pathOfService" }) issues the request against a URL relative to it. The request options are those of axiosaxiosA promise-based HTTP client for the browser and Node.js, and the client a CAP module here hands an outbound request to once the destination has been resolved., minus the ones the module takes from the destination, which its README names as authentication, the proxy settings and the baseURL; csrfProtection: true is the setting the README adds to a request that needs an X-CSRF token. The README lists the destination types it covers: internet destinations with no authentication, with basic authentication, with client credentials including Microsoft Azure and with JWT for Google Cloud Platform, plus on-premise destinations through the Cloud ConnectorCloud ConnectorSAP's on-premises agent that links SAP BTP applications to systems in a customer's own network, as a reverse invoke proxy that exposes only the systems and resources it is configured to allow.sap official, btp with no authentication or with basic authentication.
Facts
Where it sits
Who is behind it
In the atlas: maintains 17, contributes to 59, wrote 2@gregorwolfSAP Mentors & FriendsSAP Mentors & FriendsMaintains this
In the atlas: maintains 3@sapmentorsVolker BuzekVolker BuzekMaintains this
In the atlas: maintains 7, contributes to 53, wrote 2@vobumaintainersEdoBContributes to this
In the atlas: contributes to 1@EdoBRobert EijpeContributes to this
In the atlas: contributes to 1@raeijpe2 contributors
Before choosing this
Signals
ActivityQuietRelease and repository quiet for 57 months
Both observable publication channels have been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.
Conditions
PracticalFunctional boundary
The package declares @sap/cds ^4.5.2 among its dependencies and pins @sap-cloud-sdk/core at 1.37.1, so a project on CAP 5 or later is outside the range it states.
LicenceSAP Developer License Agreement 3.2 CAP§ 1from DestinationsA destination used by a covered CAP application sends SAP product data to a non-SAP product rather than only addressing a remote endpoint.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
A destination is configuration, not the deciding boundary. The licence becomes material when the resulting data flow is extraction into a non-SAP product, so the target and purpose need review.
SAP Developer License Agreement 3.2 CAP →What it declares
Every artifact
- Type
- Package
- Origin
- By a community org
- Runtime
- Node.js
As a package
- Declared for
- ^4.5.2
- Where it runs
- Inside its host
- Distributed through
- npm
Connections
Reaching remote systems without addresses or credentials in the code
Proxy from cloud apps to on-premise systems via Cloud Connector
Named, credentialed addresses of other systems resolved at runtime
A promise-based HTTP client for the browser and Node.js, and the client a CAP module here hands an outbound request to once the destination has been resolved.
Named, credentialed addresses of other systems resolved at runtime
Proxy from cloud apps to on-premise systems via Cloud Connector
Download
Install
npm add @sapmentors/cds-scp-apiDerived from the package name. No recipe recorded; the README has the configuration.
Where it sits in your app
Download
README
quoted from sapmentors/cds-scp-api under MIT, readCDS-SCP-API Node Module
CDS Extension for SAP Cloud Platform API Consumption
The node module CDS-SCP-API simplifies the consuming external API from SAP OnPremise & Cloud APIs, Microsoft Office 365 APIs, Google Cloud Platform APIs, and other REST APIs in a Cloud Application Programming (CAP) Model on the SAP Cloud Platform. The module provides:
- Fluent API consumption concept
- Endpoint and Configuration using SAP Cloud Platform Destination and Connectivity services
- Support of all kind of APIs including SAP OnPremise & Cloud OData and Rest APIs, Microsoft Office 365 APIs, Google Cloud Platform APIs and other REST APIs
- Easy API http request configuration based on Axios config options
History
Jhodel Cailan initially started the CDS Extension concept. SAP Mentor Robert Eijpe created a similar concept integrating Microsoft Azure and Google Cloud APIs into a CDS external services concept. The SAP Devtoberfest 2020 challenge brought concepts together. And this results in a CDS-SCP-API Node Module for the community, making SAP developers' lives better.
Installation
Using npm:
> npm install @sapmentors/cds-scp-api
Javascript/Node.js Code
// Load the module
const cdsapi = require("cds-scp-api");
// Create a connection
const service = await cdsapi.connect.to("SCPDestination");
// Request the API using Axios Config
let result = await service.run({
url: "/pathOfService"
})
Example Programs
Click here for examples and environment setup
Supported Destination Types
- Internet Destinations with No Authentication
- Internet Destinations with Basic Authentication
- Internet Destinations with Client Credentials Authentication (including Microsoft Azure)
- Internet Destinations with JWT token Authentication (currently only Google Cloud Platform)
- OnPremise Destination and Connectivity via Cloud Connector with No Authentication
- OnPremise Destinations and Connectivity via Cloud Connector with Basic Authentication
SCP Destination Configuration Examples
- SAP Cloud Platform Internet Destinations with No Authentication
- SAP Cloud Platform Internet Destinations with Basic Authentication
- SAP Cloud Platform Internet Destinations for Microsoft 365/Azure via MSGraph
- SAP Cloud Platform Internet Destinations for GSuite/Google Cloud Platform
CDS-SCP-API Config Settings
The CDS-SCP-API is an SAP Cloud Platform layer on top of Axios. The configuration settings of the CDS-SCP-API service.run code is simular to Axios options, which are documented here. CDS-SCP-API will ignore the Axios config settings for the authentification, the proxy settings, and the baseURL. The CDS-SCP-API retrieves these settings from the SAP Cloud Platform Destination & Connectivity services.
Compare Axios with CDS-SCP-API
-
Axios implementation
async function AxiosGetRequestwithBasicAuthentication() { return await axios({ url: 'https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=2', auth: { username: '<SAP S-number>', password: '<My password>' } }) } -
CDS-SCP-API implementation
async function InternetAPIGetRequestwithBasicAuthentication() { const service = await cdsapi.connect.to("ES5"); return await service.run({ url: "/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=2" }) }
CDS-SCP-API implementation uses relative URLs, and authorization is configured in the SAP Cloud Platform and handled by the CDS-SCP-API implementation.
Post requests with CSRF token protection
async function InternetAPIPostRequestwithBasicAuthentication() {
const product = {
"ProductID": "NL4B-101",
"TypeCode": "PR",
"Category": "Notebooks",
"Name": "Psychiatric Help",
"NameLanguage": "EN",
"Description": "",
"DescriptionLanguage": "",
"SupplierID": "0100000000",
"SupplierName": "SAP",
"TaxTarifCode": 1,
"MeasureUnit": "EA",
"WeightMeasure": "0.000",
"WeightUnit": "",
"CurrencyCode": "EUR",
"Price": "0.05",
"Width": "0.000",
"Depth": "0.000",
"Height": "0.000",
"DimUnit": "",
"CreatedAt": "\/Date(1602106635169)\/",
"ChangedAt": "\/Date(1602106635169)\/"
}
const service = await cdsapi.connect.to("ES5");
return await service.run({
url: "/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet",
method: "post",
headers: {
'content-type': 'application/json'
},
data: product,
csrfProtection: true
})
}
When request needs a X-CSRF token to fulfill, you can easily add the setting csrfProtection: true
Simultaneous requests
async function SimultaneousRequests() {
const service = await cdsapi.connect.to("ES5")
axios.all([
service.run({
url: "/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=2"
}),
service.run({
url: "/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=3"
})
])
.then(axios.spread((request1, request2) => {
console.log('Results request1: ', request1.d.results[0].Name);
console.log('Results request2: ', request2.d.results[0].Name);
}));
}History
Others providing
Compare all 13 on the Destinations page →- SAP Destination serviceSAP Destination serviceNamed, credentialed addresses of other systems, resolved at runtime — so an application holds no URL and no secret of its own, and the same code reaches a different system in every landscape.sap official, btpNamed, credentialed addresses of other systems resolved at runtime
- com.sap.cds:cds-feature-remote-odatacom.sap.cds:cds-feature-remote-odataA CAP Java feature for consuming remote OData V2 and V4 services as Remote Services, translating CQN queries into OData requests against a destination or a service binding.sap official, capRemote Services for consuming OData V2 and V4 APIs in CAP Java
- com.sap.cds:cds-integration-cloud-sdkcom.sap.cds:cds-integration-cloud-sdkA CAP Java feature that integrates the SAP Cloud SDK, so features such as remote OData and enterprise messaging resolve a destination or service binding and reach a remote REST-based service.sap official, capSAP Cloud SDK integration for remote REST services in CAP Java
- capire/s4capire/s4A pre-built integration package for SAP S/4HANA, holding the imported service definitions a CAP project would otherwise generate for itself.sap official, capPrebuilt SAP S/4HANA integration package for CAP projects
- cdsecdseResolves a destination from a CAP project's own configuration, then makes the outbound call with axios: the url, the method and the body are written at the call site.independent, capDestination resolution and axios calls from CAP configuration
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtime
- @sap-cloud-sdk/connectivity@sap-cloud-sdk/connectivityDestination lookup and the connectivity proxy — the package that turns a destination name into a reachable endpoint with credentials attached.sap official, capDestination lookup and connectivity proxy for the Cloud SDK
- @sap-cloud-sdk/http-client@sap-cloud-sdk/http-clientThe HTTP client that carries a destination's credentials, so an outbound call inherits the authentication rather than assembling it.sap official, capHTTP client carrying a destination's credentials
- @sap-cloud-sdk/odata-common@sap-cloud-sdk/odata-commonThe shared machinery under the SDK's OData and OpenAPI client generators; a dependency of the generated clients rather than something written against directly.sap official, capShared machinery under the Cloud SDK's OData and OpenAPI clients
- @sap-cloud-sdk/openapi@sap-cloud-sdk/openapiGenerated OpenAPI clients for the Cloud SDK, so a REST API described by a specification is called through typed functions.sap official, capGenerated OpenAPI clients for the Cloud SDK
- @sap-cloud-sdk/resilience@sap-cloud-sdk/resilienceTimeouts, retries and circuit breaking around a remote call, so one slow downstream system does not take the application with it.sap official, capTimeouts, retries and circuit breaking around remote calls
- @sap-cloud-sdk/util@sap-cloud-sdk/utilGeneral utilities shared across the Cloud SDK packages — a dependency, not a thing to reach for on its own.sap official, capGeneral utilities shared across the Cloud SDK packages
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Flavors
“The node module CDS-SCP-API simplifies the consuming external API from SAP OnPremise & Cloud APIs, Microsoft Office 365 APIs, Google Cloud Platform APIs, and other REST APIs in a Cloud Application Programming (CAP) Model on the SAP Cloud Platform.” — CDS-SCP-API Node Module — README, CDS Extension for SAP Cloud Platform API Consumption
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:sapmentors-cds-scp-api- JSON
- /artifacts/sapmentors-cds-scp-api.json
- MCP
- Connecting an agent