Lightweight wrapper around OVH's APIs. Handles all the hard work including credential creation and requests signing.
local OVH = require 'ovh-api'
local client = OVH.client(
"ovh-eu",
"API_KEY",
"SECRET_KEY",
"CONSUMER_KEY"
)
-- Print nice welcome message
print("Welcome"..client:get('/me')['firstname'])
The easiest way to get the latest stable release is to grab it from `luarocks
.
luarocks install ovh-api
To interact with the APIs, the SDK needs to identify itself using an
application_key
and an application_secret
. To get them, you need
to register your application. Depending the API you plan yo use, visit:
- OVH Europe
- OVH North-America
- So you Start Europe
- So you Start North America
- Kimsufi Europe
- Kimsufi North America
- RunAbove
Once created, you will obtain an application key (AK) and an application secret (AS).
To allow your application to access a customer account using the API on your behalf, you need a consumer key (CK).
Here is a sample code you can use to allow your application to access a customer's informations:
local OVH = require 'ovh-api'
local client = OVH.client(
'ovh-eu',
'API_KEY',
'SECRET_KEY',
)
local data = client:request_consumerkey({
{ method = 'GET', path = '/*'},
{ method = 'POST', path = '/*'},
{ method = 'PUT', path = '/*'}
})
print('Your consumer key is: '..data.consumerKey..'\n')
print('Visit '..data.validationUrl..' to validate the consumer key\n')
print('Press enter when validated\n')
io.read()
print('Welcome '..client:get('/me')['firstname'])
Returned consumerKey
should then be kept to avoid re-authenticating your
end-user on each use.
Note
To request full and unlimited access to the API, you may use wildcards:
client:request_consumerkey({
{ method = 'GET', path = '/*'},
{ method = 'POST', path = '/*'},
{ method = 'PUT', path = '/*'},
{ method = 'DELETE', path = '/*'}
})
Thanks to the application key / consumer key mechanism, it is possible to finely track applications having access to your data and revoke this access. This examples lists validated applications. It could easily be adapted to manage revocation too.
This example assumes an existing Configuration_ with valid API_KEY
,
SECRET_KEY
and CONSUMER_KEY
.
local OVH = require '../ovh'
-- Get configuration from environment variables
local END_POINT = os.getenv("OVH_END_POINT")
local API_KEY = os.getenv("OVH_API_KEY")
local SECRET_KEY = os.getenv("OVH_SECRET_KEY")
local CONSUMER_KEY = os.getenv("OVH_CONSUMER_KEY")
local client = OVH.client(
END_POINT,
API_KEY,
SECRET_KEY,
CONSUMER_KEY
)
local credentials = client:get('/me/api/credential', {status='validated'})
local text = 'List of validated credentials: \n'
for _, credentialId in pairs(credentials) do
local url = '/me/api/credential/'..credentialId
credential_data = client:get(url)
credentail_app = client:get(url..'/application')
local expiration = credential_data.expiration or ''
local lastUse = credential_data.expiration or ''
text = text..'Credential ID: '..credentialId..'\n'
..'Name: '..credentail_app.name..'\n'
..'Description: '..credentail_app.description..'\n'
..'Status: '..credentail_app.status..'\n'
..'Creation: '..credential_data.creation..'\n'
..'Expiration: '..expiration..'\n'
..'Last Use: '..lastUse..'\n\n'
end
print(text)
- Documentation: https://eu.api.ovh.com/
- Community support: [email protected]
- Console: https://eu.api.ovh.com/console
- Create application credentials: https://eu.api.ovh.com/createApp/
- Create script credentials (all keys at once): https://eu.api.ovh.com/createToken/
- Documentation: https://ca.api.ovh.com/
- Community support: [email protected]
- Console: https://ca.api.ovh.com/console
- Create application credentials: https://ca.api.ovh.com/createApp/
- Create script credentials (all keys at once): https://ca.api.ovh.com/createToken/
- Documentation: https://eu.api.soyoustart.com/
- Community support: [email protected]
- Console: https://eu.api.soyoustart.com/console/
- Create application credentials: https://eu.api.soyoustart.com/createApp/
- Create script credentials (all keys at once): https://eu.api.soyoustart.com/createToken/
- Documentation: https://ca.api.soyoustart.com/
- Community support: [email protected]
- Console: https://ca.api.soyoustart.com/console/
- Create application credentials: https://ca.api.soyoustart.com/createApp/
- Create script credentials (all keys at once): https://ca.api.soyoustart.com/createToken/
- Documentation: https://eu.api.kimsufi.com/
- Community support: [email protected]
- Console: https://eu.api.kimsufi.com/console/
- Create application credentials: https://eu.api.kimsufi.com/createApp/
- Create script credentials (all keys at once): https://eu.api.kimsufi.com/createToken/
- Documentation: https://ca.api.kimsufi.com/
- Community support: [email protected]
- Console: https://ca.api.kimsufi.com/console/
- Create application credentials: https://ca.api.kimsufi.com/createApp/
- Create script credentials (all keys at once): https://ca.api.kimsufi.com/createToken/
- Community support: https://community.runabove.com/
- Console: https://api.runabove.com/console/
- Create application credentials: https://api.runabove.com/createApp/
- High level SDK: https://github.com/runabove/python-runabove