i'm using RestSharp in C# to connect with Magento2 REST API.

Everythings fine, except one simple thing:

lets say i've got a product, in its JSON-DATA there is a tax_class_id "4". Inside of this tax_class_id theres a tax rate of 19% integrated. How do i get the taxrate "19" from the tax_class_id "4"?

here's the call:

var response = new RestRequest("/rest/default/V1/products/SampleProduct",Method.GET);
response.RequestFormat = DataFormat.JSON;
response.AddHeader("Authorization","Bearer " + Token);

here's the json-data from the response (all unnessary data like meta data etc. are cropped). I added some annotation "<<" for better understanding what i need

  "items": [
      "id": 1,
      "sku": "SampleProduct",
      "name": "a Simple Sample Product",
      "attribute_set_id": 4,
      "price": 4.99,            << this is with tax, i need the taxrate to get the price without tax aswell 
      "status": 1,
      "visibility": 4,
      "type_id": "simple",
      "created_at": "2017-10-04 12:11:03",
      "updated_at": "2017-10-24 10:02:50",
      "product_links": [

      "tier_prices": [

      "custom_attributes": [
          "attribute_code": "tax_class_id",
          "value": "4"      << i've got the class_id, now i must have the taxrate. Its 19% but how do i get the value "19"
  "total_count": 1

what can't be done:

- using PHP to do the Task
- changing some files to get it to work

what i have:

- the Magento 2.2 REST API
- C# as programming language to work with
- a Magento Shop with Access Token for REST API Requests, but no other physical access
- the product and all its data (except the taxrate ^^)
- the tax_class_id of the product
- the information that tax_class_id in *this* Shop for *this* product , id = 4 is 19% taxrate
- it must work with every other shop, every other tax_class_id, every other product as well, where e.g. id = 1 is 19% and id = 4 is like 7%

what i can use to get to it:

- the {TAXCLASSID} which is not the same as the {TAXRATEID}

what i need:

- the {TAXRATEID} to get the rate (e.g. 19 or 8.25)

Hope someone can help me with that task. Thanks in advantage.


After hours of wobbling around the Swagger documentation i figured it out myself:

There is no {TAXCLASSID} to {TAXRATEID} Function. You must iterate over the taxRule Repository with the following searchCriteria

field = id
value = 0
condition_type = gt

after this there is a node called "product_tax_class_ids". The Array-Index corresponds to the Array-Index in the next node "tax_rate_ids".

After that you'll have the tax_rate_id that fits to your products tax_class_id. With this you can use the Answer from BigDaddyL, edited by Manoj in this Question to get the rate by opening


and read the value in field "rate"

Thanks for you Help ;)


Looking at the swagger documentation could you not use


Do a GET to this -


to get an example response like -

     "id": 1,
     "tax_country_id": "US",
     "tax_region_id": 12,
     "region_name": "CA",
     "tax_postcode": "*",
     "rate": 8.25,
     "code": "US-CA-*-Rate 1",
     "titles": []

Rate I assume is the value you would need from this.

  • thats the point: the {tax_class_id} isnt the {TAXRATEID}. i need the {TAXRATEID} in order to get what you are mean. But thats what missing. I only got the {tax_class_id}, i need the {taxrateid}. – Daniel Alexander Karr Oct 24 '17 at 12:04
  • I added more informations to my post to make it more clearer. I need the TaxrateID, without it i can't get the rate thats true, but i only have the TaxClassID which is not the TaxrateID. – Daniel Alexander Karr Oct 24 '17 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.