API DATA SOURCE and Curl Requests

API DATA SOURCE can this do Curl Requests.

curl https://api.stripe.com/v1/charges \
   -u ...............: \
   -d amount=2000 \
   -d currency=usd \
   -d description="Charge for jenny.rosen@example.com" \
   -d source=tok_visa

you can send parameter in header or body with API EXTENSION

Interesting topic. Would be nice to have a howto, cause alot of APIs out there are explaining and documented their stuff via CURL

1 Like

I can do it via parameters but how do I handle the -u flag which is the authorization

dmx-api-datasource id=“api1” is=“dmx-fetch” url=“https://api.stripe.com/v1/charges” dmx-param:amount=“2000” dmx-param:currency=“usd”></dmx-api-datasource

1 Like

you dont need flags please try without flags.

Ok. But how would I set the authorization?

I’m pretty sure, I heard an App Connect Stripe extension was on the horizon? @Teodor

1 Like

Checking the API docs, you can also use the Authorization header with Bearer {{apikey}}. But you should not use the stripe API directly in public accessible pages. We will also be releasing a version for server connect where you can securely use secret API keys.

Can you give me an example of this implementation?

1 Like

On the API Data Source just add an Api Header, name: Authorization and value: Bearer {{apikey}}. It will create an attribute on the tag like dmx-header:authorization="Bearer {{apikey}}".

The server connect version is still in development, so for that you have to wait until it is released.

For users that want to know how to add basic authentication, the -u parameter in a Curl request.

In your browser open the console and type btoa('{{username}}:{{password}}'), replace {{username}} and {{password}} with the required credentials. It will return a base64 encoded string.

In the API Data Source just add an header, name Authorization and value Basic {{generated base64 string}}.

But please be aware that when using this in client-side script like with App Connect everyone can see you credentials. Never use it for credentials that the user may not access. You can use it for user credentials, when the user has to submit there own credentials.

Like @Freddy_Blockchain said but for @yarycling who isn’t alone, A Stripe-specific How-To would likely help a lot here for developers given the number of sites (wappler included :kissing_smiling_eyes:) using Stripe…


Oh yes! That howto for eg. stripe would also help to understand the concept of all other future API development! Highly required! Of course there are better solutions than stripe, just forgot the name :thinking:

Hey. No matter what i do i cant seem to submit:

<form is="dmx-api-form" id="apiform1" method="post" action="https://api.stripe.com/v1/charges" dmx-param:amount="100" dmx-param:currency="usd" dmx-header:authorization="Bearer sk_test_F6paz" dmx-param:source="tok" dmx-param:description="test" autosubmit="true"></form>

However if i use the define api schema once i pkugin data it works so i know the fields are correct.

Please note this a mobile development

Even in a mobile app it is possible for the user to retrieve the key out of your code. At least generate a Restricted key for your mobile app and don’t use your Secret key.

Doesn’t it submit the form? Do you see any network request if you inspect it in devtools of your browser.

1 Like

Code, Screenshot or working example with Stripe would be amazing!

I am afraid it is not possible to create tutorials for every API out there. That’s why the API providers usually have pretty good documentation on how to use their API.
We provide the tools to do this. As long as the issues are related to our tools, we can be of help but its up to you to check the API Docs.

I see that Authorization header is undefined and stripe doesn’t seem to respond. Can be a firewall or maybe Stripe blocks the request. Is there anything in the logs at the stripe dashboard?

You are right @Teodor but we could make a small section where each of us can publish the API instruction for the API we use.

If you notice sometime in the API reference people put help to use them in PHP Angular.js and other…
Every time one of us use an API can share in forum how it use it and more could write to the API developer to list instruction to use API in Wappler. In this case could be advertising for Wappler too