HOME FEATURES Insane Performance Extreme Redundancy Hardened Security Complete Control PRICING COMPANY Our Story Contact Us Careers DOCUMENTATION FAQ API Interface Blog Support Status Page Terms of Service CONTROL PANEL Search Getting Started With UpCloud’s API /API /Getting Started With UpCloud’s API API We offer a programmable API at https://api.upcloud.com, that encompasses all the functionality of our Control Panel and then some. The first step in getting started with our API is to create an API user. You can do this at the Control Panel’s My Account – Usernames view. We strongly recommend limiting the origin of allowed contacts (the “Allow contacts from”-field) for security reasons. Warning: If someone get’s access to your API they have total control over your account – be sure to handle credentials properly if you are programming automations against our API. The First API Request After you have created the API account, let’s try to get your first request working. The goal is to have the following dialogue working. GET /1.1/account HTTP/1.0 200 OK { "account" : { "credits" : "10000", "username" : "username" } } To quickly test the API, use a tool such as Postman to (or any other tool of your choice) to get started. The authentication method of our API is HTTP Basic authentication where the Authorization header should contain your API username and password base64 encoded. More precisely: # Python3 import base64 base64.b64encode("username:password".encode()) # Node.js new Buffer("username:password").toString('base64'); You should now be able to form a similar request to the following, where base64() should be replaced with your encoded credentials. Programmatically using the API The API can be accessed by any language that has proper HTTP libraries; the following snippet shows how you could access our API from Python3. import http.client conn = http.client.HTTPSConnection("api.upcloud.com") conn.request("GET", "/1.1/account", None, {"Authorization": "Basic base64_encoded_credentials"}) res = conn.getresponse() print( res.read() ) For a bit more sensible approach, the following shows how you could structure the code for a better approach. The BaseAPI forms a generic API (GET) request and it is extended by the Account class to form the same API request as above. Adding additional GET-requests would now be much easier. import http.client import json class BaseAPI: api = 'api.upcloud.com' api_v = '1.1' token = 'Basic base64_encoded_credentials' ''' Performs a GET request to a given endpoint in UpCloud's API. ''' def get(self, endpoint): conn = http.client.HTTPSConnection(self.api) url = "/" + self.api_v + endpoint headers = { "Authorization": self.token, "Content-Type": "application/json" } conn.request("GET", url, None, headers) res = conn.getresponse() self.printresponse(res.read()) ''' Prints the response (bytes) as a string to the user ''' def printresponse(self, res): data = res.decode(encoding='UTF-8') print(json.loads(data)) class Account(BaseAPI): endpoint='/account' def do(self): self.get(self.endpoint) More Take a look at the API Documentation! Related Articles Creating a New Server With UpCloud’s API How to Create a New Storage From a Backup API Documentation Cloud Concierge Contact our Support support@upcloud.com +44 20 358 80000 Monday to Friday - 7-16 CET Contact our Sales sales@upcloud.com +44 20 358 80000 Monday to Friday - 7-16 CET Popular Articles How to Set Up Load Balancing Managing Network Settings Allocating New IP addresses Resizing Storage Getting Started With UpCloud’s API Categories Accounts, Billing and Agreements API Getting Started Infrastructure and Networking Special Features Storage and Images Troubleshooting Tutorials Recent Posts Working With Preconfigured and Freely Scalable Server Models Problems With Windows Remote Desktop Services – MySQL Database Problems Services – Apache2 On Cloud Server Network Issues With Linux VM Eteläranta 12, 6th floor 00130 Helsinki Finland +44 20 358 80000 (Mon-Fri 7-16 CET) sales@upcloud.com support@upcloud.com Features Insane Performance Extreme Redundancy Hardened Security Complete Control Pricing Price list Company Our Story Contact Us Documentation FAQ API Interface Blog Support Status Page Terms of Service Language English Finnish (Suomi)