Пример #1
0
func ExampleGetSearch() {
	// This block is optional
	quandl.ApiKey = apiKey
	quandl.CacheHandler = filecache.Handler{Life: 60}
	// ---

	data, err := quandl.GetSearch("google stock", 1, 3)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Found %v results", len(data.Docs))

	// Output:
	// Found 3 results
}
Пример #2
0
func ExampleSearchResponse() {
	// This block is optional
	quandl.ApiKey = apiKey
	quandl.CacheHandler = filecache.Handler{Life: 60}
	// ---

	data, err := quandl.GetSearch("twitter", 2, 5)
	if err != nil {
		panic(err)
	}

	if data.TotalCount > 1000 {
		fmt.Println("Found more than 1000 results")
	}
	fmt.Println(data.CurrentPage)
	fmt.Println(data.PerPage)

	doc := data.Docs[0]
	fmt.Println(doc.ColumnNames)
	fmt.Println(doc.Errors)
	fmt.Println(doc.Id)
	fmt.Println(doc.SourceName)
	fmt.Println(doc.SourceCode)
	fmt.Println(doc.Code)
	fmt.Println(doc.Name[:10], "...")
	fmt.Println(doc.UrlizeName)
	fmt.Println(doc.DisplayUrl[:10], "...")
	fmt.Println(doc.Description[:20], "...")
	fmt.Println(doc.UpdatedAt[:3], "...")
	fmt.Println(doc.Frequency)
	fmt.Println(doc.FromDate[:3], "...")
	fmt.Println(doc.ToDate[:3], "...")
	fmt.Println(doc.Private)
	fmt.Println(doc.Type)
	fmt.Println(doc.Premium)

	source := data.Sources[0]
	fmt.Println(source.Id)
	fmt.Println(source.Code)
	fmt.Println(source.DataSetsCount)
	fmt.Println(source.Description[:20], "...")
	fmt.Println(source.Name)
	fmt.Println(source.Host)
	fmt.Println(source.Premium)

	// Output:
	// Found more than 1000 results
	// 2
	// 5
	// [date Followers Following Favorites Tweets Listed]
	// <nil>
	// 13811288
	// Twitter Inc.
	// TWITTER
	// TO_BE
	// to be Twit ...
	// to-be-Twitter-Metrics
	// http://twi ...
	// Collage the internet ...
	// 201 ...
	// daily
	// 201 ...
	// 201 ...
	// false

	// false
	// 12832
	// TWITTER
	// 98506
	// Official Twitter sta ...
	// Twitter Inc.
	// twitter.com
	// false

}