Skip to content

Commit 33d5ca8

Browse files
coding example files
1 parent cb1b87b commit 33d5ca8

15 files changed

+214
-0
lines changed

Diff for: code_examples/c-sharp_example.txt

+11
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+
}

Diff for: code_examples/go_example.go

+26
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+
}

Diff for: code_examples/java_example.java

+18
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+
}

Diff for: code_examples/node_example.js

+20
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()

Diff for: code_examples/php_example.php

+25
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+
}

Diff for: code_examples/python_example.py

+19
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))

Diff for: code_examples/r_example.txt

+12
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)

Diff for: code_examples/ruby_example.rb

+15
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

Diff for: code_examples/rust_example.rs

+20
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+
}

Diff for: code_examples/scala_example.scala

+5
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)

Diff for: code_examples/strest-example.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
requests:
3+
curl_converter:
4+
request:
5+
url: 'https://financialmodelingprep.com/api/v3/income-statement/AAPL'
6+
method: GET
7+
headers:
8+
-
9+
name: Upgrade-Insecure-Requests
10+
value: '1'
11+
-
12+
queryString:
13+
-
14+
name: datatype
15+
value: json
16+
-
17+
name: apikey
18+
value: YOUR_API_KEY

Diff for: code_examples/swift_example.swift

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import PlaygroundSupport
2+
3+
import Foundation
4+
5+
let url = URL(string: "https://financialmodelingprep.com/api/v3/income-statement/AAPL?apikey=YOUR_API_KEY")
6+
7+
var request = URLRequest(url: url!)
8+
9+
request.addValue("application/json", forHTTPHeaderField: "Accept")
10+
let task = URLSession.shared.dataTask(with: url!) { data, response, error in
11+
guard error == nil else {
12+
print(error!)
13+
return
14+
}
15+
guard let data = data else {
16+
print("Data is empty")
17+
return
18+
}
19+
20+
let json = try! JSONSerialization.jsonObject(with: data, options: [])
21+
print(json)
22+
}
23+
24+
task.resume()
25+
PlaygroundPage.current.needsIndefiniteExecution = true

Diff for: images/api-keys.png

9.18 KB
Loading

Diff for: images/choose-plan.png

190 KB
Loading

Diff for: images/signup-form.png

37.1 KB
Loading

0 commit comments

Comments
 (0)