Borsdata-Sweden / API

Börsdata API documentation
58 stars 6 forks source link

PHP Example #10

Open spitfire64 opened 3 years ago

spitfire64 commented 3 years ago

Please write a little sample code in OO PHP!

henrikbergstrom commented 3 years ago

Thanks, I will look at this,

spitfire64 commented 3 years ago

I have now learned how to interact with the API through PHP. A simple example for anyone that like to get started using PHP:

class Borsdata 
{
    private $base_url = 'https://apiservice.borsdata.se';
    private $version = 'v1';
    private $key = 'my_key';
    private $sleep =0.11; // Max 100 requests allowed per 10s

    function get_all_instruments_from_borsdata(){
        $endpoint = "/instruments";
        $url = $this->base_url.'/'.$this->version.'/'.$endpoint.'?authKey='.$this->key;
        $r = json_decode(file_get_contents($url), true);
        return $r['instruments'];
    }
}
spitfire64 commented 3 years ago

Tack Henrik. Jag har kommit igång själv och lagt upp lite PHP kod å gitHub ifall någon annan kan behöva lite starthjälp MVH/Mårten Hansson

On Mon, 8 Mar 2021 at 08:44, Henrik notifications@github.com wrote:

Thanks, I will look at this,

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Borsdata-Sweden/API/issues/10#issuecomment-792546056, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWACSDONMN777SEUJP5YPDTCR545ANCNFSM4V2S772A .

henrikbergstrom commented 3 years ago

Looks great! If you have some sample code, maybe I can add this to our rep? We dont have any knowledge in php.

reinew commented 2 years ago

Just published a simple (quick and dirty) php class sample code to interact with the API through PHP.

https://github.com/reinew/borsdata-api

henrikbergstrom commented 2 years ago

Thanks reinew. I added link on our startpage to your repo.

reinew commented 2 years ago

Thanks for linking but the name is wrong. It's not in python, it's php and have sample code for all the functions.

henrikbergstrom commented 2 years ago

Sorry. Now its fixed :) Thanks again