Hi, I'm really new in this world and I don't understand DO API's, I just wan't to build a page where people can add delete or update domains

October 17, 2016 72 views
API DNS DigitalOcean

I have already downloaded JAVA API and PHP API because I kind of know Java and PHP but I don't understand how to use them on my webpage

1 comment
2 Answers
xMudrii October 17, 2016
Accepted Answer

Hi guys (@nundavid99, @newbie).

For some basic introduction, I'll explain what does Java API, PHP API or any other API you find do.
DigitalOcean has API which is public available to all their users.

Only thing you need to use it, is Token, which you generate from Control Panel. Go to it -> API -> Tokens. Generate New Token, select desired permissions (read and/or write) and give it name you want. Copy it and save on secure place now as it will not appear again.

You communicate with API via HTTP requests. To communicate via HTTP requests, you need to know "endpoints". I would explain "endpoints" on something like links you need to call for some action.
We have API Docs, which explains what features API does have and how you call them. So it only says what endpoints ("links") it has. It will not learn you how to develop app for it, but it does have examples that can help a lot. You should get familiar with features of API before creating your own app.

Now to communicate with API via your app, you need to make functions in your application that will send HTTP requests to desired links. This is not hard, once you make first function, next are only copy-paste. But let's agree, this is time consuming.

So, good community members made API Wrappers. You should look like on API Wrappers like libraries that have all that functions. You don't need to write any function, you just call for example CreateDroplet(args..) and it will create Droplet for you.

First thing you need to do is find API Wrapper for you language (follow link for list of it).

Let's say we're going to use API Wrapper for PHP called - API v2 client in PHP. When you open it you will see Sammy and some basic description with link Visit Project. Click on it, it will redirect you to projects GitHub page.

Scroll down little and you will notice section starting with title README.md. There you have everything about it, from how to install it and include in your project to what does it support.
This is something I will not write here, follow it yourself, see the required dependencies, install it and see how is it working. ;)

Basically, you must find API Wrapper that have Docs. Docs are usually located in README.md of project. DO API Docs will not help with API Wrapper, as that docs explain how to use HTTP requests to do something with DO Droplets, etc... API Wrapper docs explains how to install/include it, and how to call functions.

API Wrappers can support all API functions, or less number of it. This is what you will find in docs. But it can't have more functions than original DigitalOcean HTTP API.

Beside that you should know one thing. DigitalOcean only creates Ruby API Wrapper - droplet_kit and Go API Wrapper - godo. They're officially supported by DigitalOcean and have all functions of HTTP API.
All other Wrapper you find on the Internet, or DigitalOcean Projects site is made by some random person on the Internet who was kind enough to do it for us. It is not guaranteed that it does have Docs or it'll get updates (new functions, bug fixes). So for them you will don't find tutorials on DigitalOcean community or something like that. You must reefer to their docs.

When you go on DigitalOcean API docs, on right side you will see Examples. On bottom side of it you will see something like three tabs - CURL, RUBY, GO.
Ruby and Go are basically some type tutorials how to use them. If you want to use them, you can use it as tutorial how to make something. For other languages, I already said what you need...

So first thing you should looking for in Wrapper Project Site is - Docs. Without docs you will have very hard time using it, especially as beginner.

Conclusion would be:
Basically, you will have to find API Wrapper for your language, open their Project Page and read docs. Read it few times. It'll give you idea how to use it. We can't make you site for you, you will have to do it for yourself. If you need help including libraries, try to search how do you include any library for you language. Usually on same way you would include that Wrapper.
If you stuck anywhere, you can raise a issue on Wrapper GitHub page, or ask here, maybe someone who used it will help you.

Maybe I wrote a long wall of text that didn't help you, but I hope it is good read. It explains what does DO offers, what is API wrappers (or that JAVA API, PHP API) and what you need. You don't have detailed steps but this for real beginners. Tl;dr: read docs - by reading docs, you will learn how to do it. :)

  • thank you xMudrii I really appreciate your support, I have learn a lot now and I have a new issue with the buzz adapter if someone know how to solve it please tell me

    Fatal error: Uncaught exception 'Buzz\Exception\RequestException' with message 'SSL certificate problem: unable to get local issuer certificate' in C:\xampp\htdocs\vendor\kriswallsmith\buzz\lib\Buzz\Client\Curl.php:29 Stack trace: #0 C:\xampp\htdocs\vendor\kriswallsmith\buzz\lib\Buzz\Browser.php(130): Buzz\Client\Curl->send(Object(Buzz\Message\Request), Object(Buzz\Message\Response)) #1 C:\xampp\htdocs\vendor\kriswallsmith\buzz\lib\Buzz\Browser.php(82): Buzz\Browser->send(Object(Buzz\Message\Request)) #2 C:\xampp\htdocs\vendor\kriswallsmith\buzz\lib\Buzz\Browser.php(31): Buzz\Browser->call('https://api.dig...', 'GET', Array) #3 C:\xampp\htdocs\vendor\toin0u\digitalocean-v2\src\Adapter\BuzzAdapter.php(48): Buzz\Browser->get('https://api.dig...') #4 C:\xampp\htdocs\vendor\toin0u\digitalocean-v2\src\Api\Region.php(27): DigitalOceanV2\Adapter\BuzzAdapter->get('https://api.dig...') #5 C:\xampp\htdocs\domain.php(31): DigitalOceanV2\Api\Region->getAll() #6 {main} thrown in C:\xampp\htdocs\vendor\kriswallsmith\buzz\lib\Buzz\Client\Curl.php on line 29

Learn one of the programming languages or hire a developer to do it for you.

Have another answer? Share your knowledge.