Skip to content

Commit 678d85b

Browse files
authored
Merge pull request #14 from minasm/master
Add Search API endpoint
2 parents 1a6d382 + f5f72dd commit 678d85b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/Api/Stock.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,18 @@ public function yahoo($symbol, $params = [])
106106
$this->setParams(null, $params);
107107
return $this;
108108
}
109+
110+
/**
111+
* Search API for Stocks, ETFs, Mutual Funds and Indices
112+
* url: https://eodhistoricaldata.com/financial-apis/search-api-for-stocks-etfs-mutual-funds-and-indices/
113+
* @param string $symbol
114+
* @param array $params
115+
* @return Stock
116+
*/
117+
public function search($symbol, $params = [])
118+
{
119+
$this->urlSegment = '/search';
120+
$this->setParams($symbol, $params);
121+
return $this;
122+
}
109123
}

tests/StockTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,17 @@ public function test_yahoo_api()
4949
$content = $this->stock->yahoo('AAPL.US')->json();
5050
$this->assertNotEmpty($content);
5151
}
52+
53+
public function test_search_api()
54+
{
55+
$content = $this->stock->search('AAPL.US')->json();
56+
$this->assertNotEmpty($content);
57+
}
58+
59+
public function test_search_api_filters_exchange()
60+
{
61+
62+
$content = $this->stock->search('AAPL.US', ['exchange'=>'NASDAQ'])->json();
63+
$this->assertNotEmpty($content);
64+
}
5265
}

0 commit comments

Comments
 (0)