You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 27, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+60-70Lines changed: 60 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@
3
3
semantics3-ruby is a Ruby client for accessing the Semantics3 Products API, which provides structured information, including pricing histories, for a large number of products.
4
4
See https://www.semantics3.com for more information.
Let's make our first query! For this query, we are going to search for all Toshiba products that fall under the category of "Computers and Accessories", whose cat_id is 4992.
50
+
Let's run our first request! We are going to run a simple search fo the word "iPhone" as follows:
52
51
53
52
```ruby
54
-
# Build the query
55
-
sem3.products_field( "cat_id", 4992 )
56
-
sem3.products_field( "brand", "Toshiba" )
53
+
# Build the request
54
+
sem3.products_field( "search", "iphone" )
57
55
58
-
#Make the query
56
+
#Run the request
59
57
productsHash = sem3.get_products()
60
58
61
-
# View the results of the query
59
+
# View the results of the request
62
60
puts productsHash.to_json
63
61
```
64
62
65
-
## Examples
63
+
## Sample Requests
66
64
67
-
The following examples show you how to interface with some of the core functionality of the Semantics3 Products API. For more detailed examples check out the Quickstart guide: https://www.semantics3.com/quickstart
65
+
The following requests show you how to interface with some of the core functionality of the Semantics3 Products API:
68
66
69
-
### Explore the Category Tree
67
+
### Pagination
70
68
71
-
In this example we are going to be accessing the categories endpoint. We are going to be specifically exploring the "Computers and Accessories" category, which has a cat_id of 4992. For more details regarding our category tree and associated cat_ids check out our API docs at https://www.semantics3.com/docs
69
+
The example in our "Hello World" script returns the first 10 results. In this example, we'll scroll to subsequent pages, beyond our initial request:
72
70
73
71
```ruby
74
-
# Build the query
75
-
sem3.categories_field( "cat_id", 4992 )
72
+
# Build the request
73
+
sem3.products_field( "search", "iphone" )
76
74
77
-
#Make the query
78
-
categoriesHash= sem3.get_categories()
75
+
#Run the request
76
+
productsHash= sem3.get_products()
79
77
80
-
# View the results of the query
81
-
puts categoriesHash.to_json
82
-
```
78
+
# View the results of the request
79
+
puts productsHash.to_json
83
80
84
-
### Nested Search Query
81
+
# Goto the next 'page'
82
+
page =0
83
+
while (productsHash = sem3.iterate_products) do
84
+
page = page +1
85
+
puts"We are at page = #{page}"
86
+
puts"The results for this page are:\n"
87
+
puts productsHash.to_json
88
+
end
89
+
```
85
90
86
-
You can construct complex queries by just repeatedly calling the products_field() or add() methods. Here is how we translate the following JSON query - '{"cat_id":4992,"brand":"Toshiba","weight":{"gte":1000000,"lt":1500000},"sitedetails":{"name":"newegg.com","latestoffers":{"currency":"USD","price":{"gte":100}}}}'.
91
+
### UPC Query
87
92
88
-
This query returns all Toshiba products within a certain weight range narrowed down to just those that retailed recently on newegg.com for >= USD 100.
93
+
Running a UPC/EAN/GTIN query is as simple as running a search query:
Let's now look at doing pagination, continuing from where we stopped previously.
119
+
Filter by price using the "lt" (less than) tag:
118
120
119
121
```ruby
120
-
# Goto the next 'page'
121
-
page =0
122
-
while (productsHash = sem3.iterate_products) do
123
-
page = page +1
124
-
puts"Iterating through page: #{page}"
125
-
end
122
+
sem3.products_field( "search", "iphone" )
123
+
sem3.products_field( "price", "lt", 300 )
124
+
productsHash = sem3.get_products()
125
+
puts productsHash.to_json
126
126
```
127
127
128
-
### Explore Price Histories
128
+
### Category ID Query
129
129
130
-
We shall use the add() method, which allows you to access any of the supported endpoints by just specifiying the name of the endpoint. add( "products", param1, param2, ...) is the equivalent of products_field( param1, param2, ... ), add( "offers", param1, param2, ... ) is the equivalent of offers_field( param1, param2, ...)
131
-
132
-
For this example, we are going to look at a particular product that is sold by select mercgants and whose price is >= USD 30 and seen after a specific date (specified as a UNIX timestamp).
130
+
To lookup details about a cat_id, run your request against the categories resource:
0 commit comments