Skip to content

Commit 33d5ca8

Browse files
coding example files
1 parent cb1b87b commit 33d5ca8

15 files changed

+214
-0
lines changed

code_examples/c-sharp_example.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using (var httpClient = new HttpClient())
2+
3+
{
4+
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=0afb2ef442b712afa5c85b022d5a1f6e"))
5+
6+
{
7+
request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
8+
9+
var response = await httpClient.SendAsync(request);
10+
}
11+
}

code_examples/go_example.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"log"
7+
"net/http"
8+
)
9+
10+
func main() {
11+
url := "https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY"
12+
response, err := http.Get(url)
13+
if err != nil {
14+
log.Fatal(err)
15+
}
16+
defer response.Body.Close()
17+
18+
responseData, err := ioutil.ReadAll(response.Body)
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
23+
responseString := string(responseData)
24+
25+
fmt.Println(responseString)
26+
}

code_examples/java_example.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.net.MalformedURLException;
2+
import java.net.URL;
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
import java.io.IOException;
6+
7+
public class Main
8+
{
9+
public static void main(String[] args) throws Exception {
10+
URL url = new URL("https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY");
11+
12+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {
13+
for (String line; (line = reader.readLine()) != null;) {
14+
System.out.println(line);
15+
}
16+
}
17+
}
18+
}

code_examples/node_example.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const https = require('https')
2+
3+
const options = {
4+
hostname: 'financialmodelingprep.com',
5+
port: 443,
6+
path: '/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY',
7+
method: 'GET'
8+
}
9+
10+
const req = https.request(options, (res) => {
11+
res.on('data', (d) => {
12+
process.stdout.write(d)
13+
})
14+
})
15+
16+
req.on('error', (error) => {
17+
console.error(error)
18+
})
19+
20+
req.end()

code_examples/php_example.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
set_time_limit(0);
2+
3+
$url_info = "https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY";
4+
5+
$channel = curl_init();
6+
7+
curl_setopt($channel, CURLOPT_AUTOREFERER, TRUE);
8+
curl_setopt($channel, CURLOPT_HEADER, 0);
9+
curl_setopt($channel, CURLOPT_RETURNTRANSFER, 1);
10+
curl_setopt($channel, CURLOPT_URL, $url_info);
11+
curl_setopt($channel, CURLOPT_FOLLOWLOCATION, TRUE);
12+
curl_setopt($channel, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
13+
curl_setopt($channel, CURLOPT_TIMEOUT, 0);
14+
curl_setopt($channel, CURLOPT_CONNECTTIMEOUT, 0);
15+
curl_setopt($channel, CURLOPT_SSL_VERIFYHOST, FALSE);
16+
curl_setopt($channel, CURLOPT_SSL_VERIFYPEER, FALSE);
17+
18+
$output = curl_exec($channel);
19+
20+
if (curl_error($channel)) {
21+
return 'error:' . curl_error($channel);
22+
} else {
23+
$outputJSON = json_decode($output);
24+
var_dump($outputJSON);
25+
}

code_examples/python_example.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
3+
try:
4+
# For Python 3.0 and later
5+
from urllib.request import urlopen
6+
except ImportError:
7+
# Fall back to Python 2's urllib2
8+
from urllib2 import urlopen
9+
10+
import certifi
11+
import json
12+
13+
def get_jsonparsed_data(url):
14+
response = urlopen(url, cafile=certifi.where())
15+
data = response.read().decode("utf-8")
16+
return json.loads(data)
17+
18+
url = ("https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY
19+
print(get_jsonparsed_data(url))

code_examples/r_example.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require(httr)
2+
3+
headers = c(
4+
`Upgrade-Insecure-Requests` = '1'
5+
)
6+
7+
params = list(
8+
`datatype` = 'json',
9+
`apikey` = `YOUR_API_KEY`
10+
)
11+
12+
res <- httr::GET(url = 'https://financialmodelingprep.com/api/v3/income-statement/AAPL', httr::add_headers(.headers=headers), query = params)

code_examples/ruby_example.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'net/http'
2+
require 'uri'
3+
4+
uri = URI.parse('https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY')
5+
6+
request = Net::HTTP::Get.new(uri)
7+
request['Upgrade-Insecure-Requests'] = '1'
8+
9+
req_options = {
10+
use_ssl: uri.scheme == 'https'
11+
}
12+
13+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
14+
http.request(request)
15+
end

code_examples/rust_example.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
extern crate reqwest;
2+
3+
use reqwest::headers::*;
4+
5+
fn main() -> Result<(), reqwest::Error> {
6+
7+
let mut headers = HeaderMap::new();
8+
9+
headers.insert(UPGRADE_INSECURE_REQUESTS, "1".parse().unwrap());
10+
11+
let res = reqwest::Client::new()
12+
.get("https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY")
13+
.headers(headers)
14+
.send()?
15+
.text()?;
16+
17+
println!("{}", res);
18+
19+
Ok(())
20+
}

code_examples/scala_example.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.io.Source.fromURL
2+
3+
val json = fromURL("https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY").mkString
4+
5+
print(json)

0 commit comments

Comments
 (0)