Skip to content

Commit

Permalink
Merge pull request #14 from minasm/master
Browse files Browse the repository at this point in the history
Add Search API endpoint
  • Loading branch information
jimitit authored Aug 5, 2022
2 parents 1a6d382 + f5f72dd commit 678d85b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Api/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,18 @@ public function yahoo($symbol, $params = [])
$this->setParams(null, $params);
return $this;
}

/**
* Search API for Stocks, ETFs, Mutual Funds and Indices
* url: https://eodhistoricaldata.com/financial-apis/search-api-for-stocks-etfs-mutual-funds-and-indices/
* @param string $symbol
* @param array $params
* @return Stock
*/
public function search($symbol, $params = [])
{
$this->urlSegment = '/search';
$this->setParams($symbol, $params);
return $this;
}
}
13 changes: 13 additions & 0 deletions tests/StockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@ public function test_yahoo_api()
$content = $this->stock->yahoo('AAPL.US')->json();
$this->assertNotEmpty($content);
}

public function test_search_api()
{
$content = $this->stock->search('AAPL.US')->json();
$this->assertNotEmpty($content);
}

public function test_search_api_filters_exchange()
{

$content = $this->stock->search('AAPL.US', ['exchange'=>'NASDAQ'])->json();
$this->assertNotEmpty($content);
}
}

0 comments on commit 678d85b

Please sign in to comment.