├── python ├── .gitignore ├── example.py ├── setup.py ├── README.md └── mozscape.py ├── java └── complete │ ├── lib │ ├── ant-1.6.2.jar │ └── ivy-2.1.0.jar │ ├── src │ └── com │ │ └── seomoz │ │ └── api │ │ ├── constants │ │ ├── AnchorTextConstants.java │ │ ├── TopPagesConstants.java │ │ ├── URLMetricsConstants.java │ │ └── LinksConstants.java │ │ ├── util │ │ └── ConnectionUtil.java │ │ ├── service │ │ ├── URLMetricsService.java │ │ ├── TopPagesService.java │ │ ├── LinksService.java │ │ └── AnchorTextService.java │ │ ├── response │ │ ├── AnchorTextResponse.java │ │ ├── LinksResponse.java │ │ ├── TopPagesResponse.java │ │ └── UrlResponse.java │ │ └── authentication │ │ └── Authenticator.java │ ├── ivy.xml │ └── build.xml ├── php ├── complete │ ├── constants │ │ ├── metadata_constants.php │ │ ├── anchor_text_constants.php │ │ ├── links_constants.php │ │ ├── top_pages_constants.php │ │ └── url_metrics_constants.php │ ├── services │ │ ├── abstract_service.php │ │ ├── metadata_service.php │ │ ├── url_metrics_service.php │ │ ├── top_pages_service.php │ │ ├── links_service.php │ │ └── anchor_text_service.php │ ├── examples │ │ ├── metadata_example.php │ │ ├── url_metrics_example.php │ │ ├── top_pages_example.php │ │ ├── anchor_text_example.php │ │ ├── link_metrics_example.php │ │ └── database_example.php │ ├── bootstrap.php │ ├── utilities │ │ ├── connection_utility.php │ │ └── database_utility.php │ └── authentication │ │ └── authenticator.php ├── signed_authentication_sample.php └── batching_urls_sample.php ├── README.md ├── perl ├── Changes ├── dist.ini ├── examples │ └── test.pl └── lib │ └── WebService │ └── Mozscape │ └── API.pm ├── .gitignore ├── LICENSE ├── ruby ├── signed_authentication_sample.rb └── batching_urls_sample.rb └── javascript └── node └── batching-urls-sample.js /python/.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | dist/* 3 | linkscapeapi.egg-info/* 4 | lsapi.egg-info/* 5 | *.pyc 6 | -------------------------------------------------------------------------------- /java/complete/lib/ant-1.6.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seomoz/SEOmozAPISamples/HEAD/java/complete/lib/ant-1.6.2.jar -------------------------------------------------------------------------------- /java/complete/lib/ivy-2.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seomoz/SEOmozAPISamples/HEAD/java/complete/lib/ivy-2.1.0.jar -------------------------------------------------------------------------------- /php/complete/constants/metadata_constants.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mozscape API Sample Code 2 | ======================== 3 | 4 | Welcome to the Mozscape API sample code. Please let us know if you 5 | have any questions and send along any examples you'd like to 6 | contribute. 7 | -------------------------------------------------------------------------------- /perl/Changes: -------------------------------------------------------------------------------- 1 | Revision history for Perl extension WebService-Mozscape-API 2 | 3 | 0.03 2016.05.25 4 | Rename WebService-SEOmoz-API to WebService-Mozscape-API 5 | 6 | 0.02 2011.03.20 7 | errstr when request HTTP error 8 | 9 | 0.01 2011.03.19 10 | a start 11 | -------------------------------------------------------------------------------- /perl/dist.ini: -------------------------------------------------------------------------------- 1 | name = WebService-Mozscape-API 2 | version = 0.02 3 | author = Fayland Lam 4 | license = Perl_5 5 | copyright_holder = Fayland Lam 6 | copyright_year = 2016 7 | 8 | [@Filter] 9 | bundle = @FAYLAND 10 | 11 | [Prereqs] 12 | LWP::UserAgent = 0 13 | JSON::Any = 0 14 | URI::Escape = 0 15 | Digest::SHA = 0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile ~/.gitignore_global 6 | 7 | # Ignore bundler config 8 | /.bundle 9 | 10 | # Ignore OS X Desktop Services Store files 11 | .DS_Store 12 | 13 | # Ignore RVM files 14 | .rvmrc 15 | 16 | # Ignore SCSS cache files 17 | .sass-cache/* 18 | -------------------------------------------------------------------------------- /php/complete/services/abstract_service.php: -------------------------------------------------------------------------------- 1 | authenticator = $authenticator; 14 | } 15 | 16 | /** 17 | * @return the $authenticator 18 | */ 19 | public function getAuthenticator() { 20 | return $this->authenticator; 21 | } 22 | 23 | /** 24 | * @param $authenticator the $authenticator to set 25 | */ 26 | public function setAuthenticator($authenticator) { 27 | $this->authenticator = $authenticator; 28 | } 29 | 30 | } 31 | ?> -------------------------------------------------------------------------------- /php/complete/examples/metadata_example.php: -------------------------------------------------------------------------------- 1 | setAccessID($AccessID); 15 | $authenticator->setSecretKey($SecretKey); 16 | $authenticator->setRateLimit($rateLimit); 17 | 18 | // Metadata to retrieve (metadata_constants.php) 19 | $options = array( 20 | 'updates' => METADATA_LAST_UPDATE 21 | ); 22 | 23 | $metadataService = new MetadataService($authenticator); 24 | $response = $metadataService->getMetadata($options); 25 | 26 | echo "\n\n"; 27 | print_r($response); 28 | ?> -------------------------------------------------------------------------------- /php/complete/examples/url_metrics_example.php: -------------------------------------------------------------------------------- 1 | setAccessID($AccessID); 15 | $authenticator->setSecretKey($SecretKey); 16 | $authenticator->setRateLimit($rateLimit); 17 | 18 | // URL to query 19 | $objectURL = "www.seomoz.org"; 20 | 21 | // Metrics to retrieve (url_metrics_constants.php) 22 | $cols = URLMETRICS_COL_DEFAULT; 23 | 24 | $urlMetricsService = new URLMetricsService($authenticator); 25 | $response = $urlMetricsService->getUrlMetrics($objectURL, $cols); 26 | 27 | echo "\n\n"; 28 | print_r($response); 29 | ?> -------------------------------------------------------------------------------- /perl/examples/test.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use FindBin qw/$Bin/; 6 | use lib "$Bin/../lib"; 7 | use WebService::Mozscape::API; 8 | use Data::Dumper; 9 | 10 | my $mozscape = WebService::Mozscape::API->new( 11 | accessID => $ENV{MOZSCAPE_ACCESS_ID}, 12 | secretKey => $ENV{MOZSCAPE_SECRET_KEY}, 13 | ) or die "Can't init the mozscape instance: " . $WebService::Mozscape::API::errstr; 14 | 15 | my $t = $mozscape->getUrlMetrics( { 16 | objectURL => 'moz.com/blog', 17 | } ) or die $mozscape->errstr; 18 | print Dumper(\$t); 19 | 20 | $t = $mozscape->getLinks( { 21 | objectURL => 'www.google.com', 22 | Scope => 'page_to_page', 23 | Sort => 'page_authority', 24 | Limit => 1, 25 | } ) or die $mozscape->errstr; 26 | print Dumper(\$t); 27 | 28 | 1; 29 | -------------------------------------------------------------------------------- /php/complete/examples/top_pages_example.php: -------------------------------------------------------------------------------- 1 | setAccessID($AccessID); 15 | $authenticator->setSecretKey($SecretKey); 16 | $authenticator->setRateLimit($rateLimit); 17 | 18 | // URL to query 19 | $objectURL = "www.seomoz.org"; 20 | 21 | // Metrics to retrieve (links_constants.php) 22 | $options = array( 23 | 'cols' => TOPPAGES_COL_URL, 24 | 'limit' => 10 25 | ); 26 | 27 | $topPagesService = new TopPagesService($authenticator); 28 | $response = $topPagesService->getTopPages($objectURL, $options); 29 | 30 | echo "\n\n"; 31 | print_r($response); 32 | ?> -------------------------------------------------------------------------------- /php/complete/examples/anchor_text_example.php: -------------------------------------------------------------------------------- 1 | setAccessID($AccessID); 15 | $authenticator->setSecretKey($SecretKey); 16 | $authenticator->setRateLimit($rateLimit); 17 | 18 | // URL to query 19 | $objectURL = "www.seomoz.org"; 20 | 21 | // Metrics to retrieve (anchor_text_constants.php) 22 | $options = array( 23 | 'cols' => ANCHOR_COL_TERM_OR_PHRASE, 24 | 'scope' => ANCHOR_SCOPE_TERM_TO_SUBDOMAIN, 25 | 'sort' => ANCHOR_SORT_DOMAINS_LINKING_PAGE, 26 | 'limit' => 10 27 | ); 28 | 29 | $anchorTextService = new AnchorTextService($authenticator); 30 | $response = $anchorTextService->getAnchorText($objectURL, $options); 31 | 32 | echo "\n\n"; 33 | print_r($response); 34 | ?> -------------------------------------------------------------------------------- /php/complete/bootstrap.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /php/complete/constants/anchor_text_constants.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /php/complete/examples/link_metrics_example.php: -------------------------------------------------------------------------------- 1 | setAccessID($AccessID); 15 | $authenticator->setSecretKey($SecretKey); 16 | $authenticator->setRateLimit($rateLimit); 17 | 18 | // URL to query 19 | $objectURL = "www.seomoz.org"; 20 | 21 | // Metrics to retrieve (links_constants.php) 22 | $options = array( 23 | 'scope' => LINKS_SCOPE_PAGE_TO_PAGE, 24 | 'filters' => LINKS_FILTER_EXTERNAL, 25 | 'sort' => LINKS_SORT_PAGE_AUTHORITY, 26 | 'source_cols' => URLMETRICS_COL_SUBDOMAIN, 27 | 'target_cols' => URLMETRICS_COL_SUBDOMAIN, 28 | 'link_cols' => LINKS_COL_URL, 29 | 'limit' => 10 30 | ); 31 | 32 | $linksService = new LinksService($authenticator); 33 | $response = $linksService->getLinks($objectURL, $options); 34 | 35 | echo "\n\n"; 36 | print_r($response); 37 | ?> -------------------------------------------------------------------------------- /php/complete/services/metadata_service.php: -------------------------------------------------------------------------------- 1 | getAuthenticator()->getAuthenticationStr(); 31 | 32 | $response = ConnectionUtility::makeSimpleRequest($urlToFetch); 33 | 34 | return $response; 35 | } 36 | 37 | } 38 | ?> 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2015 SEOmoz, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /php/complete/constants/links_constants.php: -------------------------------------------------------------------------------- 1 | 29 | -------------------------------------------------------------------------------- /python/example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from mozscape import Mozscape 4 | 5 | client = Mozscape( 6 | 'my-access-id', 7 | 'my-secret-key') 8 | 9 | # As you may have noticed, there are lots of columns available 10 | # I did what I could to make them easily-accessible, but there 11 | # are a lot, and the names are long. So, the API calls have 12 | # defaults 13 | 14 | # Let's get some URL metrics. Results are now an array of dictionaries 15 | # the i'th dictionary is the results for the i'th URL 16 | metrics = client.urlMetrics(['www.moz.com', 'www.moz.com/blog']) 17 | # Now let's say we only want specific columns in the results 18 | authorities = client.urlMetrics( 19 | ['www.moz.com'], 20 | Mozscape.UMCols.domainAuthority | Mozscape.UMCols.pageAuthority) 21 | # Or if you just need results for one URL 22 | mozMetrics = client.urlMetrics('www.moz.com') 23 | 24 | # Now for some anchor text results. Not available on the Free API 25 | anchorResults = client.anchorText('www.moz.com/blog') 26 | # Or for just specific columns 27 | anchorTermResults = client.anchorText( 28 | 'www.moz.com/blog', cols=Mozscape.ATCols.term) 29 | 30 | # Now for some links results 31 | links = client.links('www.moz.com') 32 | # The links API has more columns to specify, as well as sort, scope, etc. 33 | links = client.links( 34 | 'www.moz.com', scope='domain_to_domain', sort='domain_authority', 35 | filters=['external', 'nofollow'], targetCols=Mozscape.UMCols.url) 36 | -------------------------------------------------------------------------------- /ruby/signed_authentication_sample.rb: -------------------------------------------------------------------------------- 1 | require 'openssl' 2 | require 'base64' 3 | require 'cgi' 4 | require 'open-uri' 5 | 6 | # Get your access id and secret key here: http://moz.com/products/api/keys 7 | ACCESS_ID = "ACCESS_ID_HERE" 8 | SECRET_KEY = "SECRET_KEY_HERE" 9 | 10 | # Set your expires time for several minutes into the future. 11 | # Expires times excessively far in the future will not be honored by the Mozscape API. 12 | expires = Time.now.to_i + 300 13 | 14 | # Put each parameter on a new line. 15 | string_to_sign = "#{ACCESS_ID}\n#{expires}" 16 | 17 | # Get the "raw" or binary output of the hmac hash. 18 | binary_signature = OpenSSL::HMAC.digest('sha1', SECRET_KEY, string_to_sign) 19 | 20 | # Base64-encode it and then url-encode that. 21 | URL_SAFE_SIGNATURE = CGI::escape(Base64.encode64(binary_signature).chomp) 22 | 23 | # Specify the URL that you want metrics for. 24 | object_url = 'www.moz.com' 25 | 26 | # Add up all the bit flags you want returned. 27 | # Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics 28 | cols = '103079215108' 29 | 30 | # Now put your entire request together. 31 | # This example uses the Mozscape URL Metrics API. 32 | request_url = "http://lsapi.seomoz.com/linkscape/url-metrics/#{object_url}?Cols=#{cols}&AccessID=#{ACCESS_ID}&Expires=#{expires}&Signature=#{URL_SAFE_SIGNATURE}" 33 | 34 | # Go and fetch the URL 35 | response = open(request_url).read 36 | 37 | # "response" is now the JSON string returned fron the Mozscape API 38 | puts response 39 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/constants/AnchorTextConstants.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.constants; 2 | 3 | /** 4 | * 5 | * A constants class for AnchorText Service 6 | * 7 | * @author Radeep Solutions 8 | */ 9 | public class AnchorTextConstants 10 | { 11 | public static final String ANCHOR_SCOPE_PHRASE_TO_PAGE = "phrase_to_page"; 12 | public static final String ANCHOR_SCOPE_PHRASE_TO_SUBDOMAIN = "phrase_to_subdomain"; 13 | public static final String ANCHOR_SCOPE_PHRASE_TO_DOMAIN = "phrase_to_domain"; 14 | public static final String ANCHOR_SCOPE_TERM_TO_PAGE = "term_to_page"; 15 | public static final String ANCHOR_SCOPE_TERM_TO_SUBDOMAIN = "term_to_subdomain"; 16 | public static final String ANCHOR_SCOPE_TERM_TO_DOMAIN = "term_to_domain"; 17 | 18 | public static final String ANCHOR_SORT_DOMAINS_LINKING_PAGE = "domains_linking_page"; 19 | 20 | public static final long ANCHOR_COL_ALL = 0; 21 | public static final long ANCHOR_COL_TERM_OR_PHRASE = 2; 22 | public static final long ANCHOR_COL_INTERNAL_PAGES_LINK = 8; 23 | public static final long ANCHOR_COL_INTERNAL_SUBDMNS_LINK = 16; 24 | public static final long ANCHOR_COL_EXTERNAL_PAGES_LINK = 32; 25 | public static final long ANCHOR_COL_EXTERNAL_SUBDMNS_LINK = 64; 26 | public static final long ANCHOR_COL_EXTERNAL_ROOTDMNS_LINK = 128; 27 | public static final long ANCHOR_COL_INTERNAL_MOZRANK = 256; 28 | public static final long ANCHOR_COL_EXTERNAL_MOZRANK = 512; 29 | public static final long ANCHOR_COL_FLAGS = 1024; 30 | } 31 | -------------------------------------------------------------------------------- /php/signed_authentication_sample.php: -------------------------------------------------------------------------------- 1 | true 33 | ); 34 | 35 | $ch = curl_init($requestUrl); 36 | curl_setopt_array($ch, $options); 37 | $content = curl_exec($ch); 38 | curl_close($ch); 39 | 40 | print_r($content); 41 | 42 | ?> 43 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/util/ConnectionUtil.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.util; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.http.client.ClientProtocolException; 6 | import org.apache.http.client.HttpClient; 7 | import org.apache.http.client.ResponseHandler; 8 | import org.apache.http.client.methods.HttpGet; 9 | import org.apache.http.impl.client.BasicResponseHandler; 10 | import org.apache.http.impl.client.DefaultHttpClient; 11 | 12 | /** 13 | * 14 | * Utility Class to make a GET HTTP connection 15 | * to the given url and pass the output 16 | * 17 | * @author Radeep Solutions 18 | * 19 | */ 20 | public class ConnectionUtil 21 | { 22 | 23 | /** 24 | * 25 | * Method to make a GET HTTP connecton to 26 | * the given url and return the output 27 | * 28 | * @param urlToFetch url to be connected 29 | * @return the http get response 30 | */ 31 | public static String makeRequest(String urlToFetch) 32 | { 33 | HttpClient httpclient = new DefaultHttpClient(); 34 | 35 | HttpGet httpget = new HttpGet(urlToFetch); 36 | 37 | // Create a response handler 38 | ResponseHandler responseHandler = new BasicResponseHandler(); 39 | String responseBody = ""; 40 | try 41 | { 42 | responseBody = httpclient.execute(httpget, responseHandler); 43 | } 44 | catch (ClientProtocolException e) 45 | { 46 | e.printStackTrace(); 47 | } 48 | catch (IOException e) 49 | { 50 | e.printStackTrace(); 51 | } 52 | httpclient.getConnectionManager().shutdown(); 53 | return responseBody; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /php/batching_urls_sample.php: -------------------------------------------------------------------------------- 1 | true, 34 | CURLOPT_POSTFIELDS => $encodedDomains 35 | ); 36 | 37 | $ch = curl_init($requestUrl); 38 | curl_setopt_array($ch, $options); 39 | $content = curl_exec($ch); 40 | curl_close( $ch ); 41 | 42 | $contents = json_decode($content); 43 | print_r($contents); 44 | ?> 45 | -------------------------------------------------------------------------------- /ruby/batching_urls_sample.rb: -------------------------------------------------------------------------------- 1 | require 'openssl' 2 | require 'base64' 3 | require 'cgi' 4 | require 'json' 5 | require 'net/http' 6 | require 'uri' 7 | 8 | # Get your access id and secret key here: http://moz.com/products/api/keys 9 | ACCESS_ID = "ACCESS_ID_HERE" 10 | SECRET_KEY = "SECRET_KEY_HERE" 11 | 12 | # Set your expires time for several minutes into the future. 13 | # Expires times excessively far in the future will not be honored by the Mozscape API. 14 | expires = Time.now.to_i + 300 15 | 16 | # Put each parameter on a new line. 17 | string_to_sign = "#{ACCESS_ID}\n#{expires}" 18 | 19 | # Get the "raw" or binary output of the hmac hash. 20 | binary_signature = OpenSSL::HMAC.digest('sha1', SECRET_KEY, string_to_sign) 21 | 22 | # Base64-encode it and then url-encode that. 23 | URL_SAFE_SIGNATURE = CGI::escape(Base64.encode64(binary_signature).chomp) 24 | 25 | # Specify the URL that you want metrics for. 26 | object_url = 'www.moz.com' 27 | 28 | # Add up all the bit flags you want returned. 29 | # Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics 30 | cols = '103079215108' 31 | 32 | # Now put your entire request together. 33 | # This example uses the Mozscape URL Metrics API. 34 | request_url = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=#{cols}&AccessID=#{ACCESS_ID}&Expires=#{expires}&Signature=#{URL_SAFE_SIGNATURE}" 35 | 36 | # Put your URLS into an array and json_encode them. 37 | batched_domains = ['www.moz.com', 'www.apple.com', 'www.pizza.com'] 38 | encoded_domains = batched_domains.to_json 39 | 40 | # Go and fetch the URL 41 | uri = URI.parse("#{request_url}") 42 | http = Net::HTTP.new(uri.host, uri.port) 43 | request = Net::HTTP::Post.new(uri.request_uri) 44 | request.body = encoded_domains 45 | response = http.request(request) 46 | 47 | puts response.body 48 | -------------------------------------------------------------------------------- /php/complete/constants/top_pages_constants.php: -------------------------------------------------------------------------------- 1 | 39 | -------------------------------------------------------------------------------- /php/complete/examples/database_example.php: -------------------------------------------------------------------------------- 1 | setAccessID($AccessID); 15 | $authenticator->setSecretKey($SecretKey); 16 | $authenticator->setRateLimit($rateLimit); 17 | 18 | // Add your hostname here 19 | $hostname = 'localhost'; 20 | 21 | // Add your database here 22 | $database = ''; 23 | 24 | // Add your table here 25 | $table = ''; 26 | 27 | // Add your username here 28 | $username = ''; 29 | 30 | // Add your password here 31 | $password = ''; 32 | 33 | // Setup/Connect database 34 | $dbConnector = new dbConnector(); 35 | $dbConnector -> setHostname($hostname); 36 | $dbConnector -> setDatabase($database); 37 | $dbConnector -> setUsername($username); 38 | $dbConnector -> setPassword($password); 39 | $dbConnector -> connectDB(); 40 | 41 | // Query database for URLs 42 | $dbConnector -> setTable($table); 43 | $db_urls = $dbConnector->getURLsFromDB(); 44 | 45 | // Set batch size here 46 | $batchSize = 200; 47 | 48 | // Batch URLs 49 | $dbConnector -> setBatchSize($batchSize); 50 | $batchedDomains = $dbConnector->getBatchedURLs($db_urls); 51 | 52 | // Close DB connection 53 | $dbConnector -> closeDB(); 54 | 55 | echo "Batch size = $batchSize\n\n"; 56 | 57 | // Metrics to retrieve (url_metrics_constants.php) 58 | $cols = URLMETRICS_COL_DEFAULT; 59 | 60 | // Send batches to Mozscape API 61 | $i = 0; 62 | foreach ($batchedDomains as $objectURL) { 63 | $i++; 64 | 65 | $urlMetricsService = new URLMetricsService($authenticator); 66 | $response = $urlMetricsService->getUrlMetrics($objectURL, $cols); 67 | 68 | echo "\n\n"; 69 | print_r($response); 70 | } 71 | ?> -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2011-2015 SEOmoz, Moz 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining 6 | # a copy of this software and associated documentation files (the 7 | # "Software"), to deal in the Software without restriction, including 8 | # without limitation the rights to use, copy, modify, merge, publish, 9 | # distribute, sublicense, and/or sell copies of the Software, and to 10 | # permit persons to whom the Software is furnished to do so, subject to 11 | # the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be 14 | # included in all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | try: 25 | from setuptools import setup 26 | except ImportError: 27 | from distutils.core import setup 28 | 29 | setup( 30 | name='mozscape', 31 | version='0.1.1', 32 | description='Mozscape API Bindings for Python', 33 | author_email='dan@moz.com', 34 | url='http://github.com/seomoz/SEOmozAPISamples', 35 | py_modules=['mozscape'], 36 | license='MIT', 37 | platforms='Posix; MacOS X', 38 | classifiers=[ 39 | 'License :: OSI Approved :: MIT License', 40 | 'Development Status :: 3 - Alpha', 41 | 'Environment :: Web Environment', 42 | 'Intended Audience :: Developers', 43 | 'Topic :: Internet :: WWW/HTTP'], 44 | ) 45 | -------------------------------------------------------------------------------- /php/complete/services/url_metrics_service.php: -------------------------------------------------------------------------------- 1 | objectURL - if array is passed then batch request 19 | * @param string cols 20 | * @return response 21 | */ 22 | public function getUrlMetrics($objectURL, $cols) { 23 | 24 | $urlToFetch = "http://lsapi.seomoz.com/linkscape/url-metrics/"; 25 | $postParams = null; 26 | 27 | // if passed more then 1 url - pass them through post 28 | if (!is_array($objectURL)) { 29 | $urlToFetch .= urlencode($objectURL); 30 | } else { 31 | $postParams = json_encode($objectURL); 32 | } 33 | 34 | $urlToFetch .= "?" . $this->getAuthenticator()->getAuthenticationStr(); 35 | $urlToFetch .= "&Cols=" . $cols; 36 | 37 | $response = ConnectionUtility::makeRequest($urlToFetch, $postParams); 38 | 39 | $i = $this->getAuthenticator()->getRateLimit(); 40 | 41 | // if request fails retry with exponential backoff 42 | if (isset($response['http']) && $response['http'] != "200") { 43 | 44 | do { 45 | $i = $i + $i; 46 | 47 | // output message (optional) 48 | echo "\n\nERROR: HTTP Response Code (" . $response['http'] . ")"; 49 | echo "\nWaiting $i seconds to retry"; 50 | 51 | sleep($i); 52 | $response = ConnectionUtility::makeRequest($urlToFetch, $postParams); 53 | 54 | } while ($response['http'] != "200"); 55 | 56 | } 57 | 58 | unset($response['http']); 59 | 60 | return $response; 61 | } 62 | 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /php/complete/constants/url_metrics_constants.php: -------------------------------------------------------------------------------- 1 | 40 | -------------------------------------------------------------------------------- /php/complete/services/top_pages_service.php: -------------------------------------------------------------------------------- 1 | getAuthenticator()->getAuthenticationStr(); 23 | 24 | /** 25 | * @param cols - A set of metrics can be requested by indicating them as bit flags in the Cols query parameter. 26 | */ 27 | if ((isset($options['cols']) && (int)$options['cols'] > 0)) { 28 | $urlToFetch .= "&Cols=" . $options['cols']; 29 | } 30 | 31 | /** 32 | * @param offset - The start record of the page can be specified using the Offset parameter 33 | */ 34 | if (isset($options['offset']) && (int)$options['offset'] > 0) { 35 | $urlToFetch .= "&Offset=" . $options['offset']; 36 | } 37 | 38 | /** 39 | * @param limit - The size of the page can by specified using the Limit parameter. 40 | */ 41 | if ((isset($options['limit']) && (int)$options['limit'] > 0)) { 42 | $urlToFetch .= "&Limit=" . $options['limit']; 43 | } 44 | 45 | $response = ConnectionUtility::makeRequest($urlToFetch); 46 | 47 | $i = $this->getAuthenticator()->getRateLimit(); 48 | 49 | // if request fails retry with exponential backoff 50 | if (isset($response['http']) && $response['http'] != "200") { 51 | 52 | do { 53 | $i = $i + $i; 54 | 55 | // output message (optional) 56 | echo "\n\nERROR: HTTP Response Code (" . $response['http'] . ")"; 57 | echo "\nWaiting $i seconds to retry"; 58 | 59 | sleep($i); 60 | $response = ConnectionUtility::makeRequest($urlToFetch, $postParams); 61 | 62 | } while ($response['http'] != "200"); 63 | 64 | } 65 | 66 | unset($response['http']); 67 | 68 | return $response; 69 | } 70 | 71 | } 72 | ?> 73 | -------------------------------------------------------------------------------- /php/complete/utilities/connection_utility.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/service/URLMetricsService.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.service; 2 | 3 | import java.net.URLEncoder; 4 | import java.math.BigInteger; 5 | 6 | import com.seomoz.api.authentication.Authenticator; 7 | import com.seomoz.api.util.ConnectionUtil; 8 | 9 | /** 10 | * 11 | * Service class to call the various methods to 12 | * URL Metrics 13 | * 14 | * URL Metrics is a paid API that returns the metrics about a URL or set of URLs. 15 | * 16 | * @author Radeep Solutions 17 | * 18 | */ 19 | public class URLMetricsService 20 | { 21 | private Authenticator authenticator; 22 | 23 | public URLMetricsService() 24 | { 25 | 26 | } 27 | 28 | /** 29 | * 30 | * @param authenticator 31 | */ 32 | public URLMetricsService(Authenticator authenticator) 33 | { 34 | this.setAuthenticator(authenticator); 35 | } 36 | 37 | /** 38 | * 39 | * This method returns the metrics about a URL or set of URLs. 40 | * 41 | * @param objectURL 42 | * @param col This field filters the data to get only specific columns 43 | * col = 0 fetches all the data 44 | * @return 45 | */ 46 | public String getUrlMetrics(String objectURL, BigInteger col) 47 | { 48 | 49 | String urlToFetch = "http://lsapi.seomoz.com/linkscape/url-metrics/" + URLEncoder.encode(objectURL) + "?" + authenticator.getAuthenticationStr(); 50 | //System.out.println(urlToFetch); 51 | if(col.signum() == 1) 52 | { 53 | urlToFetch = urlToFetch + "&Cols=" + col; 54 | } 55 | String response = ConnectionUtil.makeRequest(urlToFetch); 56 | 57 | return response; 58 | } 59 | public String getUrlMetrics(String objectURL, long col) { return getUrlMetrics(objectURL, BigInteger.valueOf(col)); } 60 | 61 | /** 62 | * 63 | * Fetch all the Url Metrics for the objectURL 64 | * 65 | * @param objectURL 66 | * @return 67 | * 68 | * @see URLMetricsService#getUrlMetrics(String, int) 69 | */ 70 | public String getUrlMetrics(String objectURL) 71 | { 72 | return getUrlMetrics(objectURL, 0); 73 | } 74 | 75 | /** 76 | * @param authenticator the authenticator to set 77 | */ 78 | public void setAuthenticator(Authenticator authenticator) { 79 | this.authenticator = authenticator; 80 | } 81 | 82 | /** 83 | * @return the authenticator 84 | */ 85 | public Authenticator getAuthenticator() { 86 | return authenticator; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/constants/TopPagesConstants.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.constants; 2 | 3 | /** 4 | * 5 | * A constants class for TopPages Service 6 | * 7 | * @author Radeep Solutions 8 | */ 9 | public class TopPagesConstants 10 | { 11 | public static final long TOPPAGES_COL_ALL = 0; 12 | public static final long TOPPAGES_COL_TITLE = 1; 13 | public static final long TOPPAGES_COL_URL = 4; 14 | public static final long TOPPAGES_COL_SUBDOMAIN = 8; 15 | public static final long TOPPAGES_COL_ROOT_DOMAIN = 16; 16 | public static final long TOPPAGES_COL_EXTERNAL_LINKS = 32; 17 | public static final long TOPPAGES_COL_SUBDMN_EXTERNAL_LINKS = 64; 18 | public static final long TOPPAGES_COL_ROOTDMN_EXTERNAL_LINKS = 128; 19 | public static final long TOPPAGES_COL_JUICE_PASSING_LINKS = 256; 20 | public static final long TOPPAGES_COL_SUBDMN_LINKS = 512; 21 | public static final long TOPPAGES_COL_ROOTDMN_LINKS = 1024; 22 | public static final long TOPPAGES_COL_LINKS = 2048; 23 | public static final long TOPPAGES_COL_SUBDMN_SUBDMN_LINKS = 4096; 24 | public static final long TOPPAGES_COL_ROOTDMN_ROOTDMN_LINKS = 8192; 25 | public static final long TOPPAGES_COL_MOZRANK = 16384; 26 | public static final long TOPPAGES_COL_SUBDMN_MOZRANK = 32768; 27 | public static final long TOPPAGES_COL_ROOTDMN_MOZRANK = 65536; 28 | public static final long TOPPAGES_COL_MOZTRUST = 131072; 29 | public static final long TOPPAGES_COL_SUBDMN_MOZTRUST = 262144; 30 | public static final long TOPPAGES_COL_ROOTDMN_MOZTRUST = 524288; 31 | public static final long TOPPAGES_COL_EXTERNAL_MOZRANK = 1048576; 32 | public static final long TOPPAGES_COL_SUBDMN_EXTERNALDMN_JUICE = 2097152; 33 | public static final long TOPPAGES_COL_ROOTDMN_EXTERNALDMN_JUICE = 4194304; 34 | public static final long TOPPAGES_COL_SUBDMN_DOMAIN_JUICE = 8388608; 35 | public static final long TOPPAGES_COL_ROOTDMN_DOMAIN_JUICE = 16777216; 36 | public static final long TOPPAGES_COL_CANONICAL_URL = 268435456; 37 | public static final long TOPPAGES_COL_HTTP_STATUS_CODE = 536870912; 38 | public static final long TOPPAGES_COL_LINKS_TO_SUBDMN = 4294967296L; 39 | public static final long TOPPAGES_COL_LINKS_TO_ROOTDMN = 8589934592L; 40 | public static final long TOPPAGES_COL_ROOTDMN_LINKS_SUBDMN = 17179869184L; 41 | public static final long TOPPAGES_COL_PAGE_AUTHORITY = 34359738368L; 42 | public static final long TOPPAGES_COL_DOMAIN_AUTHORITY = 68719476736L; 43 | } 44 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/constants/URLMetricsConstants.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.constants; 2 | 3 | /** 4 | * 5 | * A constants class for URLMetrics Service 6 | * 7 | * @author Radeep Solutions 8 | */ 9 | public class URLMetricsConstants 10 | { 11 | public static final long URLMETRICS_COL_ALL = 0; 12 | public static final long URLMETRICS_COL_TITLE = 1; 13 | public static final long URLMETRICS_COL_URL = 4; 14 | public static final long URLMETRICS_COL_SUBDOMAIN = 8; 15 | public static final long URLMETRICS_COL_ROOT_DOMAIN = 16; 16 | public static final long URLMETRICS_COL_EXTERNAL_LINKS = 32; 17 | public static final long URLMETRICS_COL_SUBDMN_EXTERNAL_LINKS = 64; 18 | public static final long URLMETRICS_COL_ROOTDMN_EXTERNAL_LINKS = 128; 19 | public static final long URLMETRICS_COL_JUICE_PASSING_LINKS = 256; 20 | public static final long URLMETRICS_COL_SUBDMN_LINKS = 512; 21 | public static final long URLMETRICS_COL_ROOTDMN_LINKS = 1024; 22 | public static final long URLMETRICS_COL_LINKS = 2048; 23 | public static final long URLMETRICS_COL_SUBDMN_SUBDMN_LINKS = 4096; 24 | public static final long URLMETRICS_COL_ROOTDMN_ROOTDMN_LINKS = 8192; 25 | public static final long URLMETRICS_COL_MOZRANK = 16384; 26 | public static final long URLMETRICS_COL_SUBDMN_MOZRANK = 32768; 27 | public static final long URLMETRICS_COL_ROOTDMN_MOZRANK = 65536; 28 | public static final long URLMETRICS_COL_MOZTRUST = 131072; 29 | public static final long URLMETRICS_COL_SUBDMN_MOZTRUST = 262144; 30 | public static final long URLMETRICS_COL_ROOTDMN_MOZTRUST = 524288; 31 | public static final long URLMETRICS_COL_EXTERNAL_MOZRANK = 1048576; 32 | public static final long URLMETRICS_COL_SUBDMN_EXTERNALDMN_JUICE = 2097152; 33 | public static final long URLMETRICS_COL_ROOTDMN_EXTERNALDMN_JUICE = 4194304; 34 | public static final long URLMETRICS_COL_SUBDMN_DOMAIN_JUICE = 8388608; 35 | public static final long URLMETRICS_COL_ROOTDMN_DOMAIN_JUICE = 16777216; 36 | public static final long URLMETRICS_COL_CANONICAL_URL = 268435456; 37 | public static final long URLMETRICS_COL_HTTP_STATUS_CODE = 536870912; 38 | public static final long URLMETRICS_COL_LINKS_TO_SUBDMN = 4294967296L; 39 | public static final long URLMETRICS_COL_LINKS_TO_ROOTDMN = 8589934592L; 40 | public static final long URLMETRICS_COL_ROOTDMN_LINKS_SUBDMN = 17179869184L; 41 | public static final long URLMETRICS_COL_PAGE_AUTHORITY = 34359738368L; 42 | public static final long URLMETRICS_COL_DOMAIN_AUTHORITY = 68719476736L; 43 | } 44 | -------------------------------------------------------------------------------- /javascript/node/batching-urls-sample.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var crypto = require('crypto'); 4 | var http = require('http'); 5 | 6 | // `bigJs` is used for number-precision when summing the bitFlag values 7 | var bigJs = require('big.js'); 8 | 9 | // Set your expires times for several minutes into the future. 10 | // An expires time excessively far in the future will not be honored by the Mozscape API. 11 | // Divide the result of Date.now() by 1000 to make sure your result is in seconds. 12 | var expires = Math.floor((Date.now() / 1000)) + 300; 13 | var accessId = process.env.accessId; 14 | var secretKey = process.env.secretKey; 15 | 16 | // `bitFlagExampleValues` is a list of bitFlag values as strings that we'll 17 | // loop over and sum together using helper function: `sumColumnValues` 18 | var bitFlagExampleValues = ['144115188075855872', '68719476736', '34359738368']; 19 | var sumColumnValues = function(bitFlagValues) { 20 | return bitFlagValues.reduce(function (accu, bitFlag) { 21 | var accuValBig = new bigJs(accu); 22 | var bitFlagBig = new bigJs(bitFlag); 23 | var bigSum = accuValBig.plus(bitFlagBig); 24 | 25 | return bigSum.toString(); 26 | }, 0); 27 | }; 28 | 29 | // 'cols' is the sum of the bit flags representing each field you want returned. 30 | // Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics 31 | // returns "144115291155070976" 32 | var cols = sumColumnValues(bitFlagExampleValues); 33 | 34 | // Put each parameter on a new line. 35 | var stringToSign = accessId + "\n" + expires; 36 | 37 | //create the hmac hash and Base64-encode it. 38 | var signature = crypto.createHmac('sha1', secretKey).update(stringToSign).digest('base64'); 39 | //URL-encode the result of the above. 40 | signature = encodeURIComponent(signature); 41 | 42 | var postData = JSON.stringify(['www.moz.com', 'www.apple.com', 'www.pizza.com']); 43 | 44 | var options = { 45 | hostname: 'lsapi.seomoz.com', 46 | path: '/linkscape/url-metrics/?Cols=' + 47 | cols + '&AccessID=' + accessId + 48 | '&Expires=' + expires + '&Signature=' + signature, 49 | method: 'POST', 50 | headers: { 51 | 'Content-Type': 'application/json', 52 | 'Content-Length': postData.length 53 | } 54 | }; 55 | 56 | var responseData = ""; 57 | 58 | var req = http.request(options, function(response){ 59 | response.setEncoding('utf8'); 60 | response.on('data', function(chunk){ 61 | responseData += chunk; 62 | }); 63 | response.on('end', function(){ 64 | console.log(responseData); 65 | }); 66 | }); 67 | 68 | //Make the request. 69 | req.write(postData); 70 | req.end(); 71 | -------------------------------------------------------------------------------- /php/complete/authentication/authenticator.php: -------------------------------------------------------------------------------- 1 | expiresInterval; 45 | 46 | $stringToSign = $this->accessID."\n".$expires; 47 | 48 | $binarySignature = hash_hmac('sha1', $stringToSign, $this->secretKey, true); 49 | 50 | // We need to base64-encode it and then url-encode that. 51 | 52 | $urlSafeSignature = urlencode(base64_encode($binarySignature)); 53 | 54 | $authenticationStr = "AccessID=".$this->accessID."&Expires=".$expires."&Signature=".$urlSafeSignature; 55 | 56 | return $authenticationStr; 57 | } 58 | 59 | /** 60 | * @return the $accessID 61 | */ 62 | public function getAccessID() { 63 | return $this->accessID; 64 | } 65 | 66 | /** 67 | * @return the $secretKey 68 | */ 69 | public function getSecretKey() { 70 | return $this->secretKey; 71 | } 72 | 73 | /** 74 | * @param $accessID the $accessID to set 75 | */ 76 | public function setAccessID($accessID) { 77 | $this->accessID = $accessID; 78 | } 79 | 80 | /** 81 | * @param $secretKey the $secretKey to set 82 | */ 83 | public function setSecretKey($secretKey) { 84 | $this->secretKey = $secretKey; 85 | } 86 | 87 | /** 88 | * @return the $expiresInterval 89 | */ 90 | public function getExpiresInterval() { 91 | return $this->expiresInterval; 92 | } 93 | 94 | /** 95 | * @return the $rateLimit 96 | */ 97 | public function getRateLimit() { 98 | return $this->rateLimit; 99 | } 100 | 101 | /** 102 | * @param $rateLimit the $rateLimit to set 103 | */ 104 | public function setRateLimit($rateLimit) { 105 | $this->rateLimit = $rateLimit; 106 | } 107 | 108 | /** 109 | * @param $expiresInterval the $expiresInterval to set 110 | */ 111 | public function setExpiresInterval($expiresInterval) { 112 | $this->expiresInterval = $expiresInterval; 113 | } 114 | 115 | } 116 | ?> -------------------------------------------------------------------------------- /php/complete/utilities/database_utility.php: -------------------------------------------------------------------------------- 1 | hostname, $this -> username, $this -> password); 46 | @mysql_select_db($this -> database) or die( "Unable to select database"); 47 | } 48 | 49 | /** 50 | * 51 | * This method gets all the URLs from DB 52 | * 53 | * Assumes table has column named `url` 54 | */ 55 | public function getURLsFromDB() { 56 | $db_urls = mysql_query("SELECT * FROM " . $this -> table); 57 | return $db_urls; 58 | } 59 | 60 | /** 61 | * 62 | * This method batches the retrieved URLs 63 | * 64 | * Set batch_size before calling this method 65 | * 66 | * @see #setBatchSize(Integer) 67 | */ 68 | public function getBatchedURLs($db_urls) { 69 | $bulk_urls = array(); 70 | while($row = mysql_fetch_array($db_urls)) { 71 | $bulk_urls[] = $row['url']; 72 | } 73 | $batchedDomains = array_chunk($bulk_urls, $this -> batch_size, false); 74 | return $batchedDomains; 75 | } 76 | 77 | /** 78 | * 79 | * This method closes the DB connection 80 | * 81 | */ 82 | public function closeDB() { 83 | mysql_close(); 84 | } 85 | 86 | /** 87 | * @param $hostname the $hostname to set 88 | */ 89 | public function setHostname($hostname) { 90 | $this->hostname = $hostname; 91 | } 92 | 93 | /** 94 | * @param $database the $database to set 95 | */ 96 | public function setDatabase($database) { 97 | $this->database = $database; 98 | } 99 | 100 | /** 101 | * @param $username the $username to set 102 | */ 103 | public function setUsername($username) { 104 | $this->username = $username; 105 | } 106 | 107 | /** 108 | * @param $password the $password to set 109 | */ 110 | public function setPassword($password) { 111 | $this->password = $password; 112 | } 113 | 114 | /** 115 | * @param $table the $table to set 116 | */ 117 | public function setTable($table) { 118 | $this->table = $table; 119 | } 120 | 121 | /** 122 | * @param $table the $table to set 123 | */ 124 | public function setBatchSize($batch_size) { 125 | $this->batch_size = $batch_size; 126 | } 127 | 128 | } 129 | ?> -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | Python Mozscape API 2 | ==================== 3 | 4 | For more information on the Mozscape API in general, please consult the 5 | [Mozscape API Help](https://moz.com/help/guides/moz-api). 6 | 7 | The current module supports both Python 2 and 3. 8 | 9 | Installation instructions 10 | ------------------------- 11 | ```sh 12 | git clone https://github.com/seomoz/SEOmozAPISamples.git 13 | cd SEOmozAPISamples/python 14 | pip install . # or alternatively python setup.py install 15 | ``` 16 | 17 | Alternatively, you can install directly from GitHub using this 18 | invocation: 19 | 20 | ``` 21 | pip install git+https://github.com/seomoz/SEOmozAPISamples.git#egg=mozscape&subdirectory=python 22 | ``` 23 | 24 | General 25 | ------- 26 | 27 | The Mozscape class is initialized with your access id and your secret key, and 28 | then can be used to make API calls: 29 | 30 | ```python 31 | from mozscape import Mozscape 32 | client = Mozscape('my_access_id', 'my_secret_key') 33 | # Now I can make API calls! 34 | ``` 35 | 36 | All calls in this class return the deserialized json objects that the 37 | API returns. Typically these are either dictionaries, or lists of 38 | dictionaries. For the meaning of each of the resultant keys, and the 39 | bit flags for the columns you can request, consult the 40 | [Help](https://moz.com/help/guides/moz-api). 41 | 42 | URL Metrics 43 | ----------- 44 | 45 | The first API call exposed is 46 | [URL Metrics](https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics). 47 | It can provide summary information on a single (via a GET) or multiple 48 | (via a POST) url or urls. 49 | 50 | ```python 51 | # Let's get some URL metrics. Results are now an array of 52 | # dictionaries the i'th dictionary is the results for the i'th URL 53 | metrics = client.urlMetrics(['www.moz.com', 'www.moz.com']) 54 | # Now let's say we only want specific columns in the results 55 | authorities = client.urlMetrics( 56 | ['www.moz.com'], 57 | Mozscape.UMCols.domainAuthority | Mozscape.UMCols.pageAuthority) 58 | # Or if you just need results for one URL 59 | mozMetrics = client.urlMetrics('www.moz.com') 60 | ``` 61 | 62 | Anchor Text 63 | ----------- 64 | 65 | Next exposed is the 66 | [Anchor Text](https://moz.com/help/guides/moz-api/mozscape/api-reference/anchor-text-metrics) 67 | call, which returns a set of anchor text terms of phrases aggregated 68 | across links to a page or domain. 69 | 70 | ```python 71 | # Now for some anchor text results 72 | anchorResults = client.anchorText('www.moz.com/blog') 73 | # Or for just specific columns 74 | anchorTermResults = client.anchorText( 75 | 'www.moz.com/blog', cols=Mozscape.ATCols.term) 76 | ``` 77 | 78 | Links 79 | ----- 80 | 81 | Lastly, we have the 82 | [Links](https://moz.com/help/guides/moz-api/mozscape/api-reference/link-metrics) 83 | call, which returns a set of links to a page or domain. 84 | 85 | ```python 86 | # Now for some links results 87 | links = client.links('www.moz.com') 88 | # The links API has more columns to specify, as well as sort, scope, etc. 89 | links = client.links( 90 | 'wwww.moz.com', scope='domain_to_domain', sort='domain_authority', 91 | filters=['external', 'nofollow'], targetCols = Mozscape.UMCols.url) 92 | ``` 93 | -------------------------------------------------------------------------------- /php/complete/services/links_service.php: -------------------------------------------------------------------------------- 1 | getAuthenticator()->getAuthenticationStr(); 24 | 25 | // scope determines the scope of the Target link, as well as the Source results 26 | if (isset($options['scope'])) { 27 | $urlToFetch .= "&Scope=" . $options['scope']; 28 | } 29 | 30 | // filters the links returned to only include links of the specified type. You may include one or more of the following values separated by '+' 31 | if (isset($options['filters'])) { 32 | $urlToFetch .= "&Filter=" . $options['filters']; 33 | } 34 | 35 | // sort determines the sorting of the links, in combination with limit and offset, this allows fast access to the top links by several orders. 36 | if (isset($options['sort'])) { 37 | $urlToFetch .= "&Sort=" . $options['sort']; 38 | } 39 | 40 | // specifies data about the source of the link is included 41 | if (isset($options['source_cols'])) { 42 | $urlToFetch .= "&SourceCols=" . $options['source_cols']; 43 | } 44 | 45 | // specifies data about the target of the link is included 46 | if (isset($options['target_cols'])) { 47 | $urlToFetch .= "&TargetCols=" . $options['target_cols']; 48 | } 49 | 50 | // specifies data about the link itself (e.g. if the link is nofollowed) 51 | if (isset($options['link_cols'])) { 52 | $urlToFetch .= "&LinkCols=" . $options['link_cols']; 53 | } 54 | 55 | // The start record of the page can be specified using the Offset parameter 56 | if (isset($options['offset']) && (int)$options['offset'] >= 0) { 57 | $urlToFetch .= "&Offset=" . (int)$options['offset']; 58 | } 59 | 60 | // The size of the page can by specified using the Limit parameter. 61 | if (isset($options['limit']) && (int)$options['limit'] >= 0) { 62 | $urlToFetch .= "&Limit=" . (int)$options['limit']; 63 | } 64 | 65 | $response = ConnectionUtility::makeRequest($urlToFetch); 66 | 67 | $i = $this->getAuthenticator()->getRateLimit(); 68 | 69 | // if request fails retry with exponential backoff 70 | if (isset($response['http']) && $response['http'] != "200") { 71 | 72 | do { 73 | $i = $i + $i; 74 | 75 | // output message (optional) 76 | echo "\n\nERROR: HTTP Response Code (" . $response['http'] . ")"; 77 | echo "\nWaiting $i seconds to retry"; 78 | 79 | sleep($i); 80 | $response = ConnectionUtility::makeRequest($urlToFetch, $postParams); 81 | 82 | } while ($response['http'] != "200"); 83 | 84 | } 85 | 86 | unset($response['http']); 87 | 88 | return $response; 89 | } 90 | 91 | } 92 | ?> 93 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/service/TopPagesService.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.service; 2 | 3 | import java.net.URLEncoder; 4 | 5 | import com.seomoz.api.authentication.Authenticator; 6 | import com.seomoz.api.util.ConnectionUtil; 7 | import java.math.BigInteger; 8 | 9 | /** 10 | * Service class to call the various methods to 11 | * Top Pages Api 12 | * 13 | * Top pages is a paid API that returns the metrics about many URLs on a given subdomain. 14 | * 15 | * @author Radeep Solutions 16 | * 17 | */ 18 | public class TopPagesService 19 | { 20 | private Authenticator authenticator; 21 | 22 | public TopPagesService() 23 | { 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @param authenticator 30 | */ 31 | public TopPagesService(Authenticator authenticator) 32 | { 33 | this.setAuthenticator(authenticator); 34 | } 35 | 36 | /** 37 | * This method returns the metrics about many URLs on a given subdomain 38 | * 39 | * @param objectURL 40 | * @param col A set of metrics can be requested by indicating them as bit flags in the Cols query parameter. 41 | * @param offset The start record of the page can be specified using the Offset parameter 42 | * @param limit The size of the page can by specified using the Limit parameter. 43 | * @return 44 | */ 45 | public String getTopPages(String objectURL, BigInteger col, int offset, int limit) 46 | { 47 | String urlToFetch = "http://lsapi.seomoz.com/linkscape/top-pages/" + URLEncoder.encode(objectURL) + "?" + authenticator.getAuthenticationStr(); 48 | if(offset >= 0 ) 49 | { 50 | urlToFetch = urlToFetch + "&Offset=" + offset; 51 | } 52 | if(limit >= 0) 53 | { 54 | urlToFetch = urlToFetch + "&Limit=" + limit; 55 | } 56 | if(col.signum() == 1) 57 | { 58 | urlToFetch = urlToFetch + "&Cols=" + col; 59 | } 60 | //System.out.println(urlToFetch); 61 | 62 | String response = ConnectionUtil.makeRequest(urlToFetch); 63 | 64 | return response; 65 | } 66 | public String getTopPages(String objectURL, long col, int offset, int limit) { return getTopPages(objectURL, BigInteger.valueOf(col), offset, limit); } 67 | 68 | /** 69 | * 70 | * @param objectURL 71 | * @param col 72 | * @return 73 | * 74 | * @see #getTopPages(String, int, int, int) 75 | */ 76 | public String getTopPages(String objectURL, BigInteger col) 77 | { 78 | return getTopPages(objectURL, col, -1, -1); 79 | } 80 | public String getTopPages(String objectURL, long col) { return getTopPages(objectURL, BigInteger.valueOf(col)); } 81 | 82 | /** 83 | * 84 | * @param objectURL 85 | * @return 86 | * 87 | * @see #getTopPages(String, int, int, int) 88 | */ 89 | public String getTopPages(String objectURL) 90 | { 91 | return getTopPages(objectURL, 0); 92 | } 93 | 94 | /** 95 | * @param authenticator the authenticator to set 96 | */ 97 | public void setAuthenticator(Authenticator authenticator) { 98 | this.authenticator = authenticator; 99 | } 100 | 101 | /** 102 | * @return the authenticator 103 | */ 104 | public Authenticator getAuthenticator() { 105 | return authenticator; 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /java/complete/ivy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Apache Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies. 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/constants/LinksConstants.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.constants; 2 | 3 | /** 4 | * 5 | * A constants class for Links Service 6 | * 7 | * @author Radeep Solutions 8 | */ 9 | public class LinksConstants 10 | { 11 | public static final String LINKS_SCOPE_PAGE_TO_PAGE = "page_to_page"; 12 | public static final String LINKS_SCOPE_PAGE_TO_SUBDOMAIN = "page_to_subdomain"; 13 | public static final String LINKS_SCOPE_PAGE_TO_DOMAIN = "page_to_domain"; 14 | public static final String LINKS_SCOPE_DOMAIN_TO_PAGE = "domain_to_page"; 15 | public static final String LINKS_SCOPE_DOMAIN_TO_SUBDOMAIN = "domain_to_subdomain"; 16 | public static final String LINKS_SCOPE_DOMAIN_TO_DOMAIN = "domain_to_domain"; 17 | 18 | public static final String LINKS_SORT_PAGE_AUTHORITY = "page_authority"; 19 | public static final String LINKS_SORT_DOMAIN_AUTHORITY = "domain_authority"; 20 | public static final String LINKS_SORT_DOMAINS_LINKING_DOMAIN = "domains_linking_domain"; 21 | public static final String LINKS_SORT_DOMAINS_LINKING_PAGE = "domains_linking_page"; 22 | 23 | public static final String LINKS_FILTER_INTERNAL = "internal"; 24 | public static final String LINKS_FILTER_EXTERNAL = "external"; 25 | public static final String LINKS_FILTER_NOFOLLOW = "nofollow"; 26 | public static final String LINKS_FILTER_FOLLOW = "follow"; 27 | public static final String LINKS_FILTER_301 = "301"; 28 | 29 | public static final long LINKS_COL_ALL = 0; 30 | public static final long LINKS_COL_TITLE = 1; 31 | public static final long LINKS_COL_URL = 4; 32 | public static final long LINKS_COL_SUBDOMAIN = 8; 33 | public static final long LINKS_COL_ROOT_DOMAIN = 16; 34 | public static final long LINKS_COL_EXTERNAL_LINKS = 32; 35 | public static final long LINKS_COL_SUBDMN_EXTERNAL_LINKS = 64; 36 | public static final long LINKS_COL_ROOTDMN_EXTERNAL_LINKS = 128; 37 | public static final long LINKS_COL_JUICE_PASSING_LINKS = 256; 38 | public static final long LINKS_COL_SUBDMN_LINKS = 512; 39 | public static final long LINKS_COL_ROOTDMN_LINKS = 1024; 40 | public static final long LINKS_COL_LINKS = 2048; 41 | public static final long LINKS_COL_SUBDMN_SUBDMN_LINKS = 4096; 42 | public static final long LINKS_COL_ROOTDMN_ROOTDMN_LINKS = 8192; 43 | public static final long LINKS_COL_MOZRANK = 16384; 44 | public static final long LINKS_COL_SUBDMN_MOZRANK = 32768; 45 | public static final long LINKS_COL_ROOTDMN_MOZRANK = 65536; 46 | public static final long LINKS_COL_MOZTRUST = 131072; 47 | public static final long LINKS_COL_SUBDMN_MOZTRUST = 262144; 48 | public static final long LINKS_COL_ROOTDMN_MOZTRUST = 524288; 49 | public static final long LINKS_COL_EXTERNAL_MOZRANK = 1048576; 50 | public static final long LINKS_COL_SUBDMN_EXTERNALDMN_JUICE = 2097152; 51 | public static final long LINKS_COL_ROOTDMN_EXTERNALDMN_JUICE = 4194304; 52 | public static final long LINKS_COL_SUBDMN_DOMAIN_JUICE = 8388608; 53 | public static final long LINKS_COL_ROOTDMN_DOMAIN_JUICE = 16777216; 54 | public static final long LINKS_COL_CANONICAL_URL = 268435456; 55 | public static final long LINKS_COL_HTTP_STATUS_CODE = 536870912; 56 | public static final long LINKS_COL_LINKS_TO_SUBDMN = 4294967296L; 57 | public static final long LINKS_COL_LINKS_TO_ROOTDMN = 8589934592L; 58 | public static final long LINKS_COL_ROOTDMN_LINKS_SUBDMN = 17179869184L; 59 | public static final long LINKS_COL_PAGE_AUTHORITY = 34359738368L; 60 | public static final long LINKS_COL_DOMAIN_AUTHORITY = 68719476736L; 61 | } 62 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/response/AnchorTextResponse.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.response; 2 | 3 | /** 4 | * 5 | * A Pojo to capture the json response from 6 | * AnchorText Api 7 | * 8 | * @author Radeep Solutions 9 | */ 10 | public class AnchorTextResponse 11 | { 12 | private String atuef; 13 | 14 | private String atuemp; 15 | 16 | private String atuep; 17 | 18 | private String atueu; 19 | 20 | private String atuf; 21 | 22 | private String atuif; 23 | 24 | private String atuimp; 25 | 26 | private String atuiu; 27 | 28 | private String atut; 29 | 30 | /** 31 | * @return the atuef 32 | */ 33 | public String getAtuef() { 34 | return atuef; 35 | } 36 | 37 | /** 38 | * @param atuef the atuef to set 39 | */ 40 | public void setAtuef(String atuef) { 41 | this.atuef = atuef; 42 | } 43 | 44 | /** 45 | * @return the atuemp 46 | */ 47 | public String getAtuemp() { 48 | return atuemp; 49 | } 50 | 51 | /** 52 | * @param atuemp the atuemp to set 53 | */ 54 | public void setAtuemp(String atuemp) { 55 | this.atuemp = atuemp; 56 | } 57 | 58 | /** 59 | * @return the atuep 60 | */ 61 | public String getAtuep() { 62 | return atuep; 63 | } 64 | 65 | /** 66 | * @param atuep the atuep to set 67 | */ 68 | public void setAtuep(String atuep) { 69 | this.atuep = atuep; 70 | } 71 | 72 | /** 73 | * @return the atueu 74 | */ 75 | public String getAtueu() { 76 | return atueu; 77 | } 78 | 79 | /** 80 | * @param atueu the atueu to set 81 | */ 82 | public void setAtueu(String atueu) { 83 | this.atueu = atueu; 84 | } 85 | 86 | /** 87 | * @return the atuf 88 | */ 89 | public String getAtuf() { 90 | return atuf; 91 | } 92 | 93 | /** 94 | * @param atuf the atuf to set 95 | */ 96 | public void setAtuf(String atuf) { 97 | this.atuf = atuf; 98 | } 99 | 100 | /** 101 | * @return the atuif 102 | */ 103 | public String getAtuif() { 104 | return atuif; 105 | } 106 | 107 | /** 108 | * @param atuif the atuif to set 109 | */ 110 | public void setAtuif(String atuif) { 111 | this.atuif = atuif; 112 | } 113 | 114 | /** 115 | * @return the atuimp 116 | */ 117 | public String getAtuimp() { 118 | return atuimp; 119 | } 120 | 121 | /** 122 | * @param atuimp the atuimp to set 123 | */ 124 | public void setAtuimp(String atuimp) { 125 | this.atuimp = atuimp; 126 | } 127 | 128 | /** 129 | * @return the atuiu 130 | */ 131 | public String getAtuiu() { 132 | return atuiu; 133 | } 134 | 135 | /** 136 | * @param atuiu the atuiu to set 137 | */ 138 | public void setAtuiu(String atuiu) { 139 | this.atuiu = atuiu; 140 | } 141 | 142 | /** 143 | * @return the atut 144 | */ 145 | public String getAtut() { 146 | return atut; 147 | } 148 | 149 | /** 150 | * @param atut the atut to set 151 | */ 152 | public void setAtut(String atut) { 153 | this.atut = atut; 154 | } 155 | 156 | /* (non-Javadoc) 157 | * @see java.lang.Object#toString() 158 | */ 159 | @Override 160 | public String toString() { 161 | return "AnchorTextResponse [atuef=" + atuef + ", atuemp=" + atuemp 162 | + ", atuep=" + atuep + ", atueu=" + atueu + ", atuf=" + atuf 163 | + ", atuif=" + atuif + ", atuimp=" + atuimp + ", atuiu=" 164 | + atuiu + ", atut=" + atut + "]"; 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /php/complete/services/anchor_text_service.php: -------------------------------------------------------------------------------- 1 | getAuthenticator()->getAuthenticationStr(); 23 | 24 | /** 25 | * scope determines the scope of the link, and takes one of the following values: 26 | * phrase_to_page: returns a set of phrases found in links to the specified page 27 | * phrase_to_subdomain: returns a set of phrases found in links to the specified subdomain 28 | * phrase_to_domain: returns a set of phrases found in links to the specified root domain 29 | * term_to_page: returns a set of terms found in links to the specified page 30 | * term_to_subdomain: returns a a set of terms found in links to the specified subdomain 31 | * term_to_domain: returns a a set of terms found in links to the specified root domain 32 | */ 33 | if (isset($options['scope']) && $options['scope'] !== null) { 34 | $urlToFetch .= "&Scope=" . $options['scope']; 35 | } 36 | 37 | /** 38 | * sort determines the sorting of the links, in combination with limit and offset, this allows fast access to the top links by several orders: 39 | * domains_linking_page: the phrases or terms found in links from the most number of root domains linking are returned first 40 | */ 41 | if (isset($options['sort']) && $options['sort'] !== null) { 42 | $urlToFetch .= "&Sort=" . $options['sort']; 43 | } 44 | 45 | /** 46 | * cols determines what fields are returned 47 | */ 48 | if (isset($options['cols']) && (int)$options['cols'] > 0) { 49 | $urlToFetch .= "&Cols=" . (int)$options['cols']; 50 | } 51 | 52 | /** 53 | * Offset The start record of the page can be specified using the Offset parameter 54 | */ 55 | if ((isset($options['offset']) && (int)$options['offset'] > 0)) { 56 | $urlToFetch .= "&Offset=" . (int)$options['offset']; 57 | } 58 | 59 | /** 60 | * limit The size of the page can by specified using the Limit parameter. 61 | */ 62 | if ((isset($options['limit']) && (int)$options['limit'] > 0)) { 63 | $urlToFetch .= "&Limit=" . $options['limit']; 64 | } 65 | 66 | $response = ConnectionUtility::makeRequest($urlToFetch); 67 | 68 | $i = $this->getAuthenticator()->getRateLimit(); 69 | 70 | // if request fails retry with exponential backoff 71 | if (isset($response['http']) && $response['http'] != "200") { 72 | 73 | do { 74 | $i = $i + $i; 75 | 76 | // output message (optional) 77 | echo "\n\nERROR: HTTP Response Code (" . $response['http'] . ")"; 78 | echo "\nWaiting $i seconds to retry"; 79 | 80 | sleep($i); 81 | $response = ConnectionUtility::makeRequest($urlToFetch, $postParams); 82 | 83 | } while ($response['http'] != "200"); 84 | 85 | } 86 | 87 | unset($response['http']); 88 | 89 | return $response; 90 | } 91 | 92 | } 93 | ?> 94 | -------------------------------------------------------------------------------- /java/complete/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Seomoz build file 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Seomoz API]]> 48 | Copyright © 2010 Seomoz. All Rights Reserved.]]> 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | ======================================================================= 86 | Please enter configuration (or comma separated list of configurations). 87 | Available configurations are: ${ivy.configurations} 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/authentication/Authenticator.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.authentication; 2 | 3 | import java.net.URLEncoder; 4 | import java.security.InvalidKeyException; 5 | import java.security.NoSuchAlgorithmException; 6 | import java.util.Date; 7 | 8 | import javax.crypto.Mac; 9 | import javax.crypto.spec.SecretKeySpec; 10 | 11 | 12 | /** 13 | * The authentication class which is used to generate the authentication string 14 | * 15 | * @author Radeep Solutions 16 | */ 17 | public class Authenticator 18 | { 19 | private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; 20 | 21 | /** 22 | * accessID The user's Access ID 23 | */ 24 | private String accessID; 25 | 26 | /** 27 | * secretKey The user's Secret Key 28 | */ 29 | private String secretKey; 30 | 31 | /** 32 | * expiresInterval The interval after which the authentication string expires 33 | * Default 300s 34 | */ 35 | private long expiresInterval = 300; 36 | 37 | public Authenticator() 38 | { 39 | 40 | } 41 | 42 | /** 43 | * Constructor to set all the variables 44 | * 45 | * @param accessID 46 | * @param secretKey 47 | * @param expiresInterval 48 | */ 49 | public Authenticator(String accessID, String secretKey, long expiresInterval) 50 | { 51 | this.accessID = accessID; 52 | this.secretKey = secretKey; 53 | this.expiresInterval = expiresInterval; 54 | } 55 | 56 | /** 57 | * 58 | * This method calculates the authentication String based on the 59 | * user's credentials. 60 | * 61 | * Set the user credentials before calling this method 62 | * 63 | * @return the authentication string 64 | * 65 | * @see #setAccessID(String) 66 | * @see #setSecretKey(String) 67 | */ 68 | public String getAuthenticationStr() 69 | { 70 | long expires = ((new Date()).getTime())/1000 + expiresInterval; 71 | 72 | String stringToSign = accessID + "\n" + expires; 73 | 74 | SecretKeySpec signingKey = new SecretKeySpec(secretKey.getBytes(), HMAC_SHA1_ALGORITHM); 75 | 76 | // get an hmac_sha1 Mac instance and initialize with the signing key 77 | Mac mac = null; 78 | try 79 | { 80 | mac = Mac.getInstance(HMAC_SHA1_ALGORITHM); 81 | mac.init(signingKey); 82 | } 83 | catch (NoSuchAlgorithmException e) 84 | { 85 | e.printStackTrace(); 86 | return ""; 87 | } 88 | catch (InvalidKeyException e) 89 | { 90 | e.printStackTrace(); 91 | return ""; 92 | } 93 | 94 | // compute the hmac on input data bytes 95 | byte[] rawHmac = mac.doFinal(stringToSign.getBytes()); 96 | 97 | // base64-encode the hmac 98 | String urlSafeSignature = URLEncoder.encode(EncodeBase64(rawHmac)); 99 | 100 | String authenticationStr = "AccessID=" + accessID + "&Expires=" + expires + "&Signature=" + urlSafeSignature; 101 | 102 | return authenticationStr; 103 | } 104 | 105 | /** 106 | * Encodes the rawdata in Base64 format 107 | * 108 | * @param rawData 109 | * @return 110 | */ 111 | public String EncodeBase64(byte[] rawData) 112 | { 113 | return Base64.encodeBytes(rawData); 114 | } 115 | 116 | /** 117 | * @return the accessID 118 | */ 119 | public String getAccessID() { 120 | return accessID; 121 | } 122 | 123 | /** 124 | * @param accessID the accessID to set 125 | */ 126 | public void setAccessID(String accessID) { 127 | this.accessID = accessID; 128 | } 129 | 130 | /** 131 | * @return the secretKey 132 | */ 133 | public String getSecretKey() { 134 | return secretKey; 135 | } 136 | 137 | /** 138 | * @param secretKey the secretKey to set 139 | */ 140 | public void setSecretKey(String secretKey) { 141 | this.secretKey = secretKey; 142 | } 143 | 144 | /** 145 | * @return the expiresInterval 146 | */ 147 | public long getExpiresInterval() { 148 | return expiresInterval; 149 | } 150 | 151 | /** 152 | * @param expiresInterval the expiresInterval to set 153 | */ 154 | public void setExpiresInterval(long expiresInterval) { 155 | this.expiresInterval = expiresInterval; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/service/LinksService.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.service; 2 | 3 | import java.net.URLEncoder; 4 | import java.math.BigInteger; 5 | 6 | import com.seomoz.api.authentication.Authenticator; 7 | import com.seomoz.api.util.ConnectionUtil; 8 | 9 | /** 10 | * 11 | * Service class to call the various methods to 12 | * Links API 13 | * 14 | * Links api returns a set of links to a page or domain. 15 | * 16 | * @author Radeep Solutions 17 | * 18 | */ 19 | public class LinksService 20 | { 21 | private Authenticator authenticator; 22 | 23 | public LinksService() 24 | { 25 | 26 | } 27 | 28 | /** 29 | * 30 | * @param authenticator 31 | */ 32 | public LinksService(Authenticator authenticator) 33 | { 34 | this.setAuthenticator(authenticator); 35 | } 36 | 37 | /** 38 | * This method returns a set of links to a page or domain. 39 | * 40 | * @param objectURL 41 | * @param scope determines the scope of the Target link, as well as the Source results. 42 | * @param filters filters the links returned to only include links of the specified type. You may include one or more of the following values separated by '+' 43 | * @param sort determines the sorting of the links, in combination with limit and offset, this allows fast access to the top links by several orders: 44 | * @param col specifies data about the source of the link is included 45 | * @return 46 | * 47 | * @see #getLinks(String, String, String, String, int, int, int) 48 | */ 49 | public String getLinks(String objectURL, String scope, String filters, String sort, BigInteger col) 50 | { 51 | return getLinks(objectURL, scope, filters, sort, col, -1, -1); 52 | } 53 | public String getLinks(String objectURL, String scope, String filters, String sort, long col) { return getLinks(objectURL, scope, filters, sort, BigInteger.valueOf(col)); } 54 | 55 | /** 56 | * This method returns a set of links to a page or domain. 57 | * 58 | * @param objectURL 59 | * @param scope determines the scope of the Target link, as well as the Source results. 60 | * @param filters filters the links returned to only include links of the specified type. You may include one or more of the following values separated by '+' 61 | * @param sort determines the sorting of the links, in combination with limit and offset, this allows fast access to the top links by several orders: 62 | * @param col specifies data about the source of the link is included 63 | * @param offset The start record of the page can be specified using the Offset parameter 64 | * @param limit The size of the page can by specified using the Limit parameter. 65 | * @return 66 | */ 67 | public String getLinks(String objectURL, String scope, String filters, String sort, BigInteger col, int offset, int limit) 68 | { 69 | String urlToFetch = "http://lsapi.seomoz.com/linkscape/links/" + URLEncoder.encode(objectURL) + "?" + authenticator.getAuthenticationStr(); 70 | 71 | if(scope != null) 72 | { 73 | urlToFetch = urlToFetch + "&Scope=" + scope; 74 | } 75 | if(filters != null) 76 | { 77 | urlToFetch = urlToFetch + "&Filter=" + filters; 78 | } 79 | if(sort != null) 80 | { 81 | urlToFetch = urlToFetch + "&Sort=" + sort; 82 | } 83 | if(col.signum() == 1) 84 | { 85 | urlToFetch = urlToFetch + "&SourceCols=" + col; 86 | } 87 | if(offset >= 0) 88 | { 89 | urlToFetch = urlToFetch + "&Offset=" + offset; 90 | } 91 | if(limit >= 0) 92 | { 93 | urlToFetch = urlToFetch + "&Limit=" + limit; 94 | } 95 | 96 | String response = ConnectionUtil.makeRequest(urlToFetch); 97 | 98 | return response; 99 | } 100 | public String getLinks(String objectURL, String scope, String filters, String sort, long col, int offset, int limit) { return getLinks(objectURL, scope, filters, sort, BigInteger.valueOf(col), offset, limit); } 101 | 102 | /** 103 | * @param authenticator the authenticator to set 104 | */ 105 | public void setAuthenticator(Authenticator authenticator) { 106 | this.authenticator = authenticator; 107 | } 108 | 109 | /** 110 | * @return the authenticator 111 | */ 112 | public Authenticator getAuthenticator() { 113 | return authenticator; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/service/AnchorTextService.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.service; 2 | 3 | import java.net.URLEncoder; 4 | import java.math.BigInteger; 5 | 6 | import com.seomoz.api.authentication.Authenticator; 7 | import com.seomoz.api.util.ConnectionUtil; 8 | 9 | /** 10 | * Service class to call the various methods to 11 | * Anchor Text API 12 | * 13 | * Anchor Text api returns a set of anchor text terms of phrases aggregated across links to a page or domain. 14 | * 15 | * @author Radeep Solutions 16 | * 17 | */ 18 | public class AnchorTextService 19 | { 20 | private Authenticator authenticator; 21 | 22 | public AnchorTextService() 23 | { 24 | 25 | } 26 | 27 | /** 28 | * 29 | * @param authenticator 30 | */ 31 | public AnchorTextService(Authenticator authenticator) 32 | { 33 | this.setAuthenticator(authenticator); 34 | } 35 | 36 | /** 37 | * 38 | * @param objectURL 39 | * @param scope 40 | * @param sort 41 | * @param col 42 | * @return a set of anchor text terms of phrases aggregated across links to a page or domain. 43 | * 44 | * @see #getAnchorText(String, String, String, int, int, int) 45 | */ 46 | public String getAnchorText(String objectURL, String scope, String sort, BigInteger col) 47 | { 48 | return getAnchorText(objectURL, scope, sort, col, -1, -1); 49 | } 50 | public String getAnchorText(String objectURL, String scope, String sort, long col) { return getAnchorText(objectURL, scope, sort, BigInteger.valueOf(col)); } 51 | 52 | /** 53 | * This method returns a set of anchor text terms of phrases aggregated across links to a page or domain. 54 | * 55 | * @param objectURL 56 | * @param scope determines the scope of the link, and takes one of the following values: 57 | * phrase_to_page: returns a set of phrases found in links to the specified page 58 | * phrase_to_subdomain: returns a set of phrases found in links to the specified subdomain 59 | * phrase_to_domain: returns a set of phrases found in links to the specified root domain 60 | * term_to_page: returns a set of terms found in links to the specified page 61 | * term_to_subdomain: returns a a set of terms found in links to the specified subdomain 62 | * term_to_domain: returns a a set of terms found in links to the specified root domain 63 | * @param sort etermines the sorting of the links, in combination with limit and offset, this allows fast access to the top links by several orders: 64 | * domains_linking_page: the phrases or terms found in links from the most number of root domains linking are returned first 65 | * @param col determines what fields are returned 66 | * @param offset The start record of the page can be specified using the Offset parameter 67 | * @param limit The size of the page can by specified using the Limit parameter. 68 | * @return a set of anchor text terms of phrases aggregated across links to a page or domain. 69 | */ 70 | public String getAnchorText(String objectURL, String scope, String sort, BigInteger col, int offset, int limit) 71 | { 72 | String urlToFetch = "http://lsapi.seomoz.com/linkscape/anchor-text/" + URLEncoder.encode(objectURL) + "?" + authenticator.getAuthenticationStr(); 73 | 74 | if(scope != null) 75 | { 76 | urlToFetch = urlToFetch + "&Scope=" + scope; 77 | } 78 | if(sort != null) 79 | { 80 | urlToFetch = urlToFetch + "&Sort=" + sort; 81 | } 82 | if(col.signum() == 1) 83 | { 84 | urlToFetch = urlToFetch + "&Cols=" + col; 85 | } 86 | 87 | if(offset >= 0) 88 | { 89 | urlToFetch = urlToFetch + "&Offset=" + offset; 90 | } 91 | if(limit >= 0) 92 | { 93 | urlToFetch = urlToFetch + "&Limit=" + limit; 94 | } 95 | String response = ConnectionUtil.makeRequest(urlToFetch); 96 | 97 | return response; 98 | } 99 | public String getAnchorText(String objectURL, String scope, String sort, long col, int offset, int limit) { return getAnchorText(objectURL, scope, sort, BigInteger.valueOf(col), offset, limit); } 100 | 101 | /** 102 | * @param authenticator the authenticator to set 103 | */ 104 | public void setAuthenticator(Authenticator authenticator) { 105 | this.authenticator = authenticator; 106 | } 107 | 108 | /** 109 | * @return the authenticator 110 | */ 111 | public Authenticator getAuthenticator() { 112 | return authenticator; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /perl/lib/WebService/Mozscape/API.pm: -------------------------------------------------------------------------------- 1 | package WebService::Mozscape::API; 2 | 3 | # ABSTRACT: Mozscape API 4 | 5 | use strict; 6 | use warnings; 7 | use LWP::UserAgent; 8 | use URI::Escape qw/uri_escape/; 9 | use Digest::SHA; 10 | use JSON::Any; 11 | use vars qw/$errstr/; 12 | 13 | =pod 14 | 15 | =head1 SYNOPSIS 16 | 17 | use WebService::Mozscape::API; 18 | 19 | my $mozscape = WebService::Mozscape::API->new( 20 | accessID => $accessID, 21 | secretKey => $secretKey, 22 | expiresInterval => $expiresInterval, # optional, default 300s 23 | ) or die "Can't init the mozscape instance: " . $WebService::Mozscape::API::errstr; 24 | 25 | my $t = $mozscape->getUrlMetrics( { 26 | objectURL => 'moz.com/blog', 27 | } ) or die $mozscape->errstr; 28 | 29 | $t = $mozscape->getLinks( { 30 | objectURL => 'www.google.com', 31 | Scope => 'page_to_page', 32 | Sort => 'page_authority', 33 | Limit => 1, 34 | } ) or die $mozscape->errstr; 35 | 36 | =head1 DESCRIPTION 37 | 38 | L 39 | 40 | =head2 METHODS 41 | 42 | =head3 CONSTRUCTION 43 | 44 | my $mozscape = WebService::Mozscape::API->new( 45 | accessID => $accessID, 46 | secretKey => $secretKey, 47 | expiresInterval => $expiresInterval, # optional, default 300s 48 | ); 49 | 50 | =over 4 51 | 52 | =item * accessID 53 | 54 | =item * secretKey 55 | 56 | get them from https://moz.com/products/api/keys after signup 57 | 58 | =item * ua_args 59 | 60 | passed to LWP::UserAgent 61 | 62 | =item * ua 63 | 64 | L or L instance 65 | 66 | =back 67 | 68 | =cut 69 | 70 | sub new { 71 | my $class = shift; 72 | my $args = scalar @_ % 2 ? shift : { @_ }; 73 | 74 | $args->{accessID} or do { $errstr = 'accessID is required'; return; }; 75 | $args->{secretKey} or do { $errstr = 'secretKey is required'; return; }; 76 | 77 | $args->{expiresInterval} ||= 300; 78 | 79 | # we won't have space before/after accessID/secretKey 80 | $args->{accessID} =~ s/(^\s+|\s+$)//g; 81 | $args->{secretKey} =~ s/(^\s+|\s+$)//g; 82 | 83 | unless ( $args->{ua} ) { 84 | my $ua_args = delete $args->{ua_args} || { timeout => 120 }; 85 | $args->{ua} = LWP::UserAgent->new(%$ua_args); 86 | } 87 | unless ( $args->{json} ) { 88 | $args->{json} = JSON::Any->new; 89 | } 90 | 91 | bless $args, $class; 92 | } 93 | 94 | sub errstr { $errstr } 95 | 96 | sub getAuthenticationStr { 97 | my ($self) = @_; 98 | 99 | my $expires = time() + $self->{expiresInterval}; 100 | my $stringToSign = $self->{accessID} . "\n" . $expires; 101 | 102 | # my $binarySignature = Digest::SHA::hmac_sha1($stringToSign, $self->{secretKey}); 103 | # We need to base64-encode it and then url-encode that. 104 | # my $urlSafeSignature = uri_escape(encode_base64($binarySignature)); 105 | 106 | # no idea why we need append '%3D' 107 | my $urlSafeSignature = uri_escape(Digest::SHA::hmac_sha1_base64($stringToSign, $self->{secretKey})) . '%3D'; 108 | my $authenticationStr = "AccessID=" . $self->{accessID} . "&Expires=" . $expires . "&Signature=" . $urlSafeSignature; 109 | 110 | return $authenticationStr; 111 | } 112 | 113 | sub makeRequest { 114 | my ($self, $url) = @_; 115 | 116 | # print STDERR "# get $url\n"; 117 | 118 | undef $errstr; 119 | 120 | my $resp = $self->{ua}->get($url); 121 | unless ($resp->is_success) { 122 | $errstr = $resp->status_line; 123 | return; 124 | } 125 | 126 | return $self->{json}->jsonToObj($resp->content); 127 | } 128 | 129 | =pod 130 | 131 | =head3 getUrlMetrics 132 | 133 | my $t = $mozscape->getUrlMetrics( { 134 | objectURL => 'moz.com/blog', 135 | } ); 136 | 137 | L 138 | 139 | =cut 140 | 141 | sub getUrlMetrics { 142 | my $self = shift; 143 | my $args = scalar @_ % 2 ? shift : { @_ }; 144 | 145 | my $objectURL = $args->{objectURL} or do { $errstr = 'objectURL is required'; return; }; 146 | my $urlToFetch = 'http://lsapi.seomoz.com/linkscape/url-metrics/' . uri_escape($objectURL) . '?' . $self->getAuthenticationStr(); 147 | 148 | foreach my $k ('Cols') { 149 | if (defined $args->{$k}) { 150 | $urlToFetch .= '&' . "$k=" . $args->{$k}; 151 | } 152 | } 153 | 154 | return $self->makeRequest($urlToFetch); 155 | } 156 | 157 | =pod 158 | 159 | =head3 getLinks 160 | 161 | my $t = $mozscape->getLinks( { 162 | objectURL => 'www.google.com', 163 | Scope => 'page_to_page', 164 | Filter => 'internal 301', 165 | Sort => 'page_authority', 166 | SourceCols => 536870916, 167 | TargetCols => 4, 168 | Limit => 1, 169 | } ); 170 | 171 | L 172 | 173 | =cut 174 | 175 | sub getLinks { 176 | my $self = shift; 177 | my $args = scalar @_ % 2 ? shift : { @_ }; 178 | 179 | my $objectURL = $args->{objectURL} or do { $errstr = 'objectURL is required'; return; }; 180 | my $urlToFetch = 'http://lsapi.seomoz.com/linkscape/links/' . uri_escape($objectURL) . '?' . $self->getAuthenticationStr(); 181 | 182 | foreach my $k ('Scope', 'Filter', 'Sort', 'SourceCols', 'TargetCols', 'LinkCols', 'Offset', 'Limit') { 183 | if (defined $args->{$k}) { 184 | $urlToFetch .= '&' . "$k=" . $args->{$k}; 185 | } 186 | } 187 | 188 | return $self->makeRequest($urlToFetch); 189 | } 190 | 191 | =pod 192 | 193 | =head3 getAnchorText 194 | 195 | my $t = $mozscape->getAnchorText( { 196 | objectURL => 'www.google.com', 197 | Scope => 'page_to_page', 198 | Sort => 'page_authority', 199 | Cols => 536870916, 200 | Offset => 4, 201 | Limit => 1, 202 | } ); 203 | 204 | L 205 | 206 | =cut 207 | 208 | sub getAnchorText { 209 | my $self = shift; 210 | my $args = scalar @_ % 2 ? shift : { @_ }; 211 | 212 | my $objectURL = $args->{objectURL} or do { $errstr = 'objectURL is required'; return; }; 213 | my $urlToFetch = 'http://lsapi.seomoz.com/linkscape/anchor-text/' . uri_escape($objectURL) . '?' . $self->getAuthenticationStr(); 214 | 215 | foreach my $k ('Scope', 'Sort', 'Cols', 'Offset', 'Limit') { 216 | if (defined $args->{$k}) { 217 | $urlToFetch .= '&' . "$k=" . $args->{$k}; 218 | } 219 | } 220 | 221 | return $self->makeRequest($urlToFetch); 222 | } 223 | 224 | 1; 225 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/response/LinksResponse.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.response; 2 | 3 | /** 4 | * 5 | * A Pojo to capture the json response from 6 | * Links Api 7 | * 8 | * @author Radeep Solutions 9 | */ 10 | public class LinksResponse 11 | { 12 | private String lrid; 13 | 14 | private String lsrc; 15 | 16 | private String ltgt; 17 | 18 | private String lufmrp; 19 | 20 | private String lufmrr; 21 | 22 | private String lufrid; 23 | 24 | private String lupda; 25 | 26 | private String luprid; 27 | 28 | private String luueid; 29 | 30 | private String luufq; 31 | 32 | private String luuid; 33 | 34 | private String luumrp; 35 | 36 | private String luumrr; 37 | 38 | private String luupa; 39 | 40 | private String luupl; 41 | 42 | private String luus; 43 | 44 | private String luut; 45 | 46 | private String luuu; 47 | 48 | private String uu; 49 | 50 | /** 51 | * @return the lrid 52 | */ 53 | public String getLrid() { 54 | return lrid; 55 | } 56 | 57 | /** 58 | * @param lrid the lrid to set 59 | */ 60 | public void setLrid(String lrid) { 61 | this.lrid = lrid; 62 | } 63 | 64 | /** 65 | * @return the lsrc 66 | */ 67 | public String getLsrc() { 68 | return lsrc; 69 | } 70 | 71 | /** 72 | * @param lsrc the lsrc to set 73 | */ 74 | public void setLsrc(String lsrc) { 75 | this.lsrc = lsrc; 76 | } 77 | 78 | /** 79 | * @return the ltgt 80 | */ 81 | public String getLtgt() { 82 | return ltgt; 83 | } 84 | 85 | /** 86 | * @param ltgt the ltgt to set 87 | */ 88 | public void setLtgt(String ltgt) { 89 | this.ltgt = ltgt; 90 | } 91 | 92 | /** 93 | * @return the lufmrp 94 | */ 95 | public String getLufmrp() { 96 | return lufmrp; 97 | } 98 | 99 | /** 100 | * @param lufmrp the lufmrp to set 101 | */ 102 | public void setLufmrp(String lufmrp) { 103 | this.lufmrp = lufmrp; 104 | } 105 | 106 | /** 107 | * @return the lufmrr 108 | */ 109 | public String getLufmrr() { 110 | return lufmrr; 111 | } 112 | 113 | /** 114 | * @param lufmrr the lufmrr to set 115 | */ 116 | public void setLufmrr(String lufmrr) { 117 | this.lufmrr = lufmrr; 118 | } 119 | 120 | /** 121 | * @return the lufrid 122 | */ 123 | public String getLufrid() { 124 | return lufrid; 125 | } 126 | 127 | /** 128 | * @param lufrid the lufrid to set 129 | */ 130 | public void setLufrid(String lufrid) { 131 | this.lufrid = lufrid; 132 | } 133 | 134 | /** 135 | * @return the lupda 136 | */ 137 | public String getLupda() { 138 | return lupda; 139 | } 140 | 141 | /** 142 | * @param lupda the lupda to set 143 | */ 144 | public void setLupda(String lupda) { 145 | this.lupda = lupda; 146 | } 147 | 148 | /** 149 | * @return the luprid 150 | */ 151 | public String getLuprid() { 152 | return luprid; 153 | } 154 | 155 | /** 156 | * @param luprid the luprid to set 157 | */ 158 | public void setLuprid(String luprid) { 159 | this.luprid = luprid; 160 | } 161 | 162 | /** 163 | * @return the luueid 164 | */ 165 | public String getLuueid() { 166 | return luueid; 167 | } 168 | 169 | /** 170 | * @param luueid the luueid to set 171 | */ 172 | public void setLuueid(String luueid) { 173 | this.luueid = luueid; 174 | } 175 | 176 | /** 177 | * @return the luufq 178 | */ 179 | public String getLuufq() { 180 | return luufq; 181 | } 182 | 183 | /** 184 | * @param luufq the luufq to set 185 | */ 186 | public void setLuufq(String luufq) { 187 | this.luufq = luufq; 188 | } 189 | 190 | /** 191 | * @return the luuid 192 | */ 193 | public String getLuuid() { 194 | return luuid; 195 | } 196 | 197 | /** 198 | * @param luuid the luuid to set 199 | */ 200 | public void setLuuid(String luuid) { 201 | this.luuid = luuid; 202 | } 203 | 204 | /** 205 | * @return the luumrp 206 | */ 207 | public String getLuumrp() { 208 | return luumrp; 209 | } 210 | 211 | /** 212 | * @param luumrp the luumrp to set 213 | */ 214 | public void setLuumrp(String luumrp) { 215 | this.luumrp = luumrp; 216 | } 217 | 218 | /** 219 | * @return the luumrr 220 | */ 221 | public String getLuumrr() { 222 | return luumrr; 223 | } 224 | 225 | /** 226 | * @param luumrr the luumrr to set 227 | */ 228 | public void setLuumrr(String luumrr) { 229 | this.luumrr = luumrr; 230 | } 231 | 232 | /** 233 | * @return the luupa 234 | */ 235 | public String getLuupa() { 236 | return luupa; 237 | } 238 | 239 | /** 240 | * @param luupa the luupa to set 241 | */ 242 | public void setLuupa(String luupa) { 243 | this.luupa = luupa; 244 | } 245 | 246 | /** 247 | * @return the luupl 248 | */ 249 | public String getLuupl() { 250 | return luupl; 251 | } 252 | 253 | /** 254 | * @param luupl the luupl to set 255 | */ 256 | public void setLuupl(String luupl) { 257 | this.luupl = luupl; 258 | } 259 | 260 | /** 261 | * @return the luus 262 | */ 263 | public String getLuus() { 264 | return luus; 265 | } 266 | 267 | /** 268 | * @param luus the luus to set 269 | */ 270 | public void setLuus(String luus) { 271 | this.luus = luus; 272 | } 273 | 274 | /** 275 | * @return the luut 276 | */ 277 | public String getLuut() { 278 | return luut; 279 | } 280 | 281 | /** 282 | * @param luut the luut to set 283 | */ 284 | public void setLuut(String luut) { 285 | this.luut = luut; 286 | } 287 | 288 | /** 289 | * @return the luuu 290 | */ 291 | public String getLuuu() { 292 | return luuu; 293 | } 294 | 295 | /** 296 | * @param luuu the luuu to set 297 | */ 298 | public void setLuuu(String luuu) { 299 | this.luuu = luuu; 300 | } 301 | 302 | /** 303 | * @return the uu 304 | */ 305 | public String getUu() { 306 | return uu; 307 | } 308 | 309 | /** 310 | * @param uu the uu to set 311 | */ 312 | public void setUu(String uu) { 313 | this.uu = uu; 314 | } 315 | 316 | /* (non-Javadoc) 317 | * @see java.lang.Object#toString() 318 | */ 319 | @Override 320 | public String toString() { 321 | return "LinksResponse [lrid=" + lrid + ", lsrc=" + lsrc + ", ltgt=" 322 | + ltgt + ", lufmrp=" + lufmrp + ", lufmrr=" + lufmrr 323 | + ", lufrid=" + lufrid + ", lupda=" + lupda + ", luprid=" 324 | + luprid + ", luueid=" + luueid + ", luufq=" + luufq 325 | + ", luuid=" + luuid + ", luumrp=" + luumrp + ", luumrr=" 326 | + luumrr + ", luupa=" + luupa + ", luupl=" + luupl + ", luus=" 327 | + luus + ", luut=" + luut + ", luuu=" + luuu + ", uu=" + uu 328 | + "]"; 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/response/TopPagesResponse.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.response; 2 | 3 | /** 4 | * 5 | * A Pojo to capture the json response from 6 | * TopPages Api 7 | * 8 | * @author Radeep Solutions 9 | */ 10 | public class TopPagesResponse 11 | { 12 | private String lrid; 13 | 14 | private String lsrc; 15 | 16 | private String ltgt; 17 | 18 | private String lufmrp; 19 | 20 | private String lufmrr; 21 | 22 | private String lufrid; 23 | 24 | private String lupda; 25 | 26 | private String luprid; 27 | 28 | private String luueid; 29 | 30 | private String luufq; 31 | 32 | private String luuid; 33 | 34 | private String luumrp; 35 | 36 | private String luumrr; 37 | 38 | private String luupa; 39 | 40 | private String luupl; 41 | 42 | private String luus; 43 | 44 | private String luut; 45 | 46 | private String luuu; 47 | 48 | private String uu; 49 | 50 | /** 51 | * @return the lrid 52 | */ 53 | public String getLrid() { 54 | return lrid; 55 | } 56 | 57 | /** 58 | * @param lrid the lrid to set 59 | */ 60 | public void setLrid(String lrid) { 61 | this.lrid = lrid; 62 | } 63 | 64 | /** 65 | * @return the lsrc 66 | */ 67 | public String getLsrc() { 68 | return lsrc; 69 | } 70 | 71 | /** 72 | * @param lsrc the lsrc to set 73 | */ 74 | public void setLsrc(String lsrc) { 75 | this.lsrc = lsrc; 76 | } 77 | 78 | /** 79 | * @return the ltgt 80 | */ 81 | public String getLtgt() { 82 | return ltgt; 83 | } 84 | 85 | /** 86 | * @param ltgt the ltgt to set 87 | */ 88 | public void setLtgt(String ltgt) { 89 | this.ltgt = ltgt; 90 | } 91 | 92 | /** 93 | * @return the lufmrp 94 | */ 95 | public String getLufmrp() { 96 | return lufmrp; 97 | } 98 | 99 | /** 100 | * @param lufmrp the lufmrp to set 101 | */ 102 | public void setLufmrp(String lufmrp) { 103 | this.lufmrp = lufmrp; 104 | } 105 | 106 | /** 107 | * @return the lufmrr 108 | */ 109 | public String getLufmrr() { 110 | return lufmrr; 111 | } 112 | 113 | /** 114 | * @param lufmrr the lufmrr to set 115 | */ 116 | public void setLufmrr(String lufmrr) { 117 | this.lufmrr = lufmrr; 118 | } 119 | 120 | /** 121 | * @return the lufrid 122 | */ 123 | public String getLufrid() { 124 | return lufrid; 125 | } 126 | 127 | /** 128 | * @param lufrid the lufrid to set 129 | */ 130 | public void setLufrid(String lufrid) { 131 | this.lufrid = lufrid; 132 | } 133 | 134 | /** 135 | * @return the lupda 136 | */ 137 | public String getLupda() { 138 | return lupda; 139 | } 140 | 141 | /** 142 | * @param lupda the lupda to set 143 | */ 144 | public void setLupda(String lupda) { 145 | this.lupda = lupda; 146 | } 147 | 148 | /** 149 | * @return the luprid 150 | */ 151 | public String getLuprid() { 152 | return luprid; 153 | } 154 | 155 | /** 156 | * @param luprid the luprid to set 157 | */ 158 | public void setLuprid(String luprid) { 159 | this.luprid = luprid; 160 | } 161 | 162 | /** 163 | * @return the luueid 164 | */ 165 | public String getLuueid() { 166 | return luueid; 167 | } 168 | 169 | /** 170 | * @param luueid the luueid to set 171 | */ 172 | public void setLuueid(String luueid) { 173 | this.luueid = luueid; 174 | } 175 | 176 | /** 177 | * @return the luufq 178 | */ 179 | public String getLuufq() { 180 | return luufq; 181 | } 182 | 183 | /** 184 | * @param luufq the luufq to set 185 | */ 186 | public void setLuufq(String luufq) { 187 | this.luufq = luufq; 188 | } 189 | 190 | /** 191 | * @return the luuid 192 | */ 193 | public String getLuuid() { 194 | return luuid; 195 | } 196 | 197 | /** 198 | * @param luuid the luuid to set 199 | */ 200 | public void setLuuid(String luuid) { 201 | this.luuid = luuid; 202 | } 203 | 204 | /** 205 | * @return the luumrp 206 | */ 207 | public String getLuumrp() { 208 | return luumrp; 209 | } 210 | 211 | /** 212 | * @param luumrp the luumrp to set 213 | */ 214 | public void setLuumrp(String luumrp) { 215 | this.luumrp = luumrp; 216 | } 217 | 218 | /** 219 | * @return the luumrr 220 | */ 221 | public String getLuumrr() { 222 | return luumrr; 223 | } 224 | 225 | /** 226 | * @param luumrr the luumrr to set 227 | */ 228 | public void setLuumrr(String luumrr) { 229 | this.luumrr = luumrr; 230 | } 231 | 232 | /** 233 | * @return the luupa 234 | */ 235 | public String getLuupa() { 236 | return luupa; 237 | } 238 | 239 | /** 240 | * @param luupa the luupa to set 241 | */ 242 | public void setLuupa(String luupa) { 243 | this.luupa = luupa; 244 | } 245 | 246 | /** 247 | * @return the luupl 248 | */ 249 | public String getLuupl() { 250 | return luupl; 251 | } 252 | 253 | /** 254 | * @param luupl the luupl to set 255 | */ 256 | public void setLuupl(String luupl) { 257 | this.luupl = luupl; 258 | } 259 | 260 | /** 261 | * @return the luus 262 | */ 263 | public String getLuus() { 264 | return luus; 265 | } 266 | 267 | /** 268 | * @param luus the luus to set 269 | */ 270 | public void setLuus(String luus) { 271 | this.luus = luus; 272 | } 273 | 274 | /** 275 | * @return the luut 276 | */ 277 | public String getLuut() { 278 | return luut; 279 | } 280 | 281 | /** 282 | * @param luut the luut to set 283 | */ 284 | public void setLuut(String luut) { 285 | this.luut = luut; 286 | } 287 | 288 | /** 289 | * @return the luuu 290 | */ 291 | public String getLuuu() { 292 | return luuu; 293 | } 294 | 295 | /** 296 | * @param luuu the luuu to set 297 | */ 298 | public void setLuuu(String luuu) { 299 | this.luuu = luuu; 300 | } 301 | 302 | /** 303 | * @return the uu 304 | */ 305 | public String getUu() { 306 | return uu; 307 | } 308 | 309 | /** 310 | * @param uu the uu to set 311 | */ 312 | public void setUu(String uu) { 313 | this.uu = uu; 314 | } 315 | 316 | /* (non-Javadoc) 317 | * @see java.lang.Object#toString() 318 | */ 319 | @Override 320 | public String toString() { 321 | return "TopPagesResponse [lrid=" + lrid + ", lsrc=" + lsrc + ", ltgt=" 322 | + ltgt + ", lufmrp=" + lufmrp + ", lufmrr=" + lufmrr 323 | + ", lufrid=" + lufrid + ", lupda=" + lupda + ", luprid=" 324 | + luprid + ", luueid=" + luueid + ", luufq=" + luufq 325 | + ", luuid=" + luuid + ", luumrp=" + luumrp + ", luumrr=" 326 | + luumrr + ", luupa=" + luupa + ", luupl=" + luupl + ", luus=" 327 | + luus + ", luut=" + luut + ", luuu=" + luuu + ", uu=" + uu 328 | + "]"; 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /python/mozscape.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | import hashlib 3 | import hmac 4 | import time 5 | import base64 6 | 7 | 8 | try: 9 | # For Python 3.0 and later 10 | from urllib.parse import urlencode, quote 11 | except ImportError: 12 | # Fall back to Python 2's urllib 13 | from urllib import urlencode, quote 14 | 15 | try: 16 | # For Python 3.0 and later 17 | from urllib.request import urlopen 18 | except ImportError: 19 | # Fall back to Python 2's urllib2 20 | from urllib2 import urlopen 21 | 22 | try: 23 | # For Python 3.0 and later 24 | from urllib.error import HTTPError 25 | except ImportError: 26 | # Fall back to Python 2's urllib2 27 | from urllib2 import HTTPError 28 | 29 | try: 30 | # Try to use the more efficient alternative 31 | import simplejson as json 32 | except: 33 | # But fall back to a built-in implementation 34 | import json 35 | 36 | 37 | class MozscapeError(Exception): 38 | """A wrapper so that we can catch our own errors""" 39 | 40 | def __init__(self, value): 41 | self.value = value 42 | 43 | def __str__(self): 44 | return str(self.value) 45 | 46 | def __repr__(self): 47 | return repr(self.value) 48 | 49 | 50 | class Mozscape: 51 | """An object that is tied to your id/key pair and can make requests on 52 | your behalf.""" 53 | 54 | class UMCols: 55 | """UrlMetric columns""" 56 | # Flags for urlMetrics 57 | # 58 | # Title of page, if available. 59 | # Free? Yes 60 | # Response code: ut 61 | title = 1 62 | # Canonical form of the url. 63 | # Free? Yes 64 | # Response code: uu 65 | url = 4 66 | # The subdomain of the url. 67 | # Free? No 68 | # Response code: ufq 69 | subdomain = 8 70 | # The root domain of the url. 71 | # Free? No 72 | # Response code: upl 73 | rootDomain = 16 74 | # The number of external quity links to the url. 75 | # Free? Yes 76 | # Response code: ueid 77 | equityExternalLinks = 32 78 | # The number of juice-passing external links to the subdomain. 79 | # Free? No 80 | # Response code: feid 81 | subdomainExternalLinks = 64 82 | # The number of juice-passing external links. 83 | # Free? No 84 | # Response code: peid 85 | rootDomainExternalLinks = 128 86 | # The number of equity (juice-passing) links (internal or 87 | # external) to the url. 88 | # Free? No 89 | # Response code: ujid 90 | juicePassingLinks = 256 91 | # The number of subdomains with any pages linking to the url. 92 | # Free? No 93 | # Response code: uifq 94 | subdomainsLinking = 512 95 | # The number of root domains with any pages linking to the url. 96 | # Free? No 97 | # Response code: uipl 98 | rootDomainsLinking = 1024 99 | # The number of links (juice-passing or not, internal or 100 | # external) to the url. 101 | # Free? yes 102 | # Response code: uid 103 | links = 2048 104 | # The number of subdomains with any pages linking to the 105 | # subdomain of the url. 106 | # Free? No 107 | # Response code: fid 108 | subdomainSubdomainsLinking = 4096 109 | # The number of root domains with any pages linking to the 110 | # root domain of the url. 111 | # Free? No 112 | # Response code: pid 113 | rootDomainRootDomainsLinking = 8192 114 | # The mozRank of the url. Requesting this metric will provide 115 | # both the pretty 10-point score (in umrp) and the raw score 116 | # (umrr). 117 | # Free? Yes 118 | # Response codes: umrp, umrr 119 | mozRank = 16384 120 | # The mozRank of the subdomain of the url. Requesting this 121 | # metric will provide both the pretty 10-point score (fmrp) 122 | # and the raw score (fmrr). 123 | # Free? Yes 124 | # Response codes: fmrp, fmrr 125 | subdomainMozRank = 32768 126 | # The mozRank of the Root Domain of the url. Requesting this 127 | # metric will provide both the pretty 10-point score (pmrp) 128 | # and the raw score (pmrr). 129 | # Free? No 130 | # Response code: pmrp, pmrr 131 | rootDomainMozRank = 65536 132 | # The mozTrust of the url. Requesting this metric will provide both the 133 | # pretty 10-point score (utrp) and the raw score (utrr). 134 | # Free? No 135 | # Response code: utrp, utrr 136 | mozTrust = 131072 137 | # The mozTrust of the subdomain of the url. Requesting this 138 | # metric will provide both the pretty 10-point score (ftrp) 139 | # and the raw score (ftrr). 140 | # Free? No 141 | # Response code: ftrp, ftrr 142 | subdomainMozTrust = 262144 143 | # The mozTrust of the root domain of the url. Requesting this 144 | # metric will provide both the pretty 10-point score (ptrp) 145 | # and the raw score (ptrr). 146 | # Free? No 147 | # Response codes: ptrp, ptrr 148 | rootDomainMozTrust = 524288 149 | # The portion of the url's mozRank coming from external links. 150 | # Requesting this metric will provide both the pretty 10-point 151 | # score (uemrp) and the raw score (uemrr). 152 | # Free? No 153 | # Response codes: uemrp, uemrr 154 | externalMozRank = 1048576 155 | # The portion of the mozRank of all pages on the subdomain 156 | # coming from external links. Requesting this metric will 157 | # provide both the pretty 10-point score (fejp) and the raw 158 | # score (fejr). 159 | # Free? No 160 | # Response codes: fejp, fejr 161 | subdomainExternalDomainJuice = 2097152 162 | # The portion of the mozRank of all pages on the root domain 163 | # coming from external links. Requesting this metric will 164 | # provide both the pretty 10-point score (pejp) and the raw 165 | # score (pejr). 166 | # Free? No 167 | # Response code: pejp, pejr 168 | rootDomainExternalDomainJuice = 4194304 169 | # The mozRank of all pages on the subdomain combined. 170 | # Requesting this metric will provide both the pretty 10-point 171 | # score (fjp) and the raw score (fjr). 172 | # Free? No 173 | # Response codes: fjp, fjr 174 | subdomainDomainJuice = 8388608 175 | # The mozRank of all pages on the root domain combined. 176 | # Requesting this metric will provide both the pretty 10-point 177 | # score (pjp) and the raw score (pjr). 178 | # Free? No 179 | # Response codes: pjp, pjr 180 | rootDomainDomainJuice = 16777216 181 | # Returns six different columns related to the Spam Score(TM) metric: 182 | # - Spam score for the page's subdomain (fspsc) 183 | # - Bit field of triggered spam flags (fspf) 184 | # - Language of the subdomain (flan) 185 | # - HTTP status code of the spam crawl (fsps) 186 | # - Epoch time when the subdomain was last crawled (fsplc) 187 | # - List of pages used for the subdomain's spam crawl (fspp). 188 | # Free? No 189 | # Response codes: fspsc, fspf, flan, fsps, fsplc, fspp 190 | subdomainSpamScore = 67108864 191 | # Returns social contact information found on the target entity: 192 | # - Facebook account (ffb) 193 | # - Twitter handle (ftw) 194 | # - Google+ account (fg+) 195 | # - Email address (fem)* 196 | # * Emails in the Contacts column are collected automatically, 197 | # and are not CAN-SPAM compliant - they cannot be used in 198 | # outbound mail campaigns. 199 | # Free? No 200 | # Response codes: ffb, ftw, fg+, fem* 201 | social = 134217728 202 | # The HTTP status code recorded by Linkscape for this URL (if 203 | # available). 204 | # Free? Yes 205 | # Response code: us 206 | httpStatusCode = 536870912 207 | # Total links (including internal and nofollow links) to the 208 | # subdomain of the url in question. 209 | # Free? No 210 | # Response code: fuid 211 | linksToSubdomain = 4294967296 212 | # Total links (including internal and nofollow links) to the 213 | # root domain of the url in question. 214 | # Free? No 215 | # Response code: puid 216 | linksToRootDomain = 8589934592 217 | # The number of root domains with at least one link to the subdomain of 218 | # the url in question. 219 | # Free? No 220 | # Response code: fipl 221 | rootDomainsLinkingToSubdomain = 17179869184 222 | # A score out of 100-points representing the likelihood for 223 | # arbitrary content to rank on this page. 224 | # Free? Yes 225 | # Response code: upa 226 | pageAuthority = 34359738368 227 | # A score out of 100-points representing the likelihood for 228 | # arbitrary content to rank on this domain. 229 | # Free? Yes 230 | # Response code: pda 231 | domainAuthority = 68719476736 232 | # The number of external links to the URL, including nofollowed links. 233 | # Free? No 234 | # Response code: ued 235 | externalLinks = 549755813888 236 | # The number of external links to the subdomain, including 237 | # nofollowed links. 238 | # Free? No 239 | # Response code: fed 240 | externalLinksToSubdomain = 140737488355328 241 | # The number of external links to the root domain, including 242 | # nofollowed links. 243 | # Free? No 244 | # Response code: ped 245 | externalLinksToRootDomain = 2251799813685248 246 | # The number of links from the same C class IP addresses. 247 | # Free? No 248 | # Response code: pib 249 | linkingCBlocks = 36028797018963968 250 | # The time and date on which Mozscape last crawled the URL, 251 | # returned in Unix epoch format. (http://www.epochconverter.com/) 252 | # Free? Yes 253 | # Response code: ulc 254 | timeLastCrawled = 144115188075855872 255 | 256 | # This is the set of all free fields 257 | freeCols = ( 258 | title | 259 | url | 260 | equityExternalLinks | 261 | links | 262 | mozRank | 263 | subdomainMozRank | 264 | httpStatusCode | 265 | pageAuthority | 266 | domainAuthority | 267 | timeLastCrawled) 268 | 269 | class ATCols: 270 | """Anchor Text Cols""" 271 | # The anchor text term or phrase 272 | term = 2 273 | # The number of internal pages linking with this term or phrase 274 | internalPagesLinking = 8 275 | # The number of subdomains on the same root domain with at 276 | # least one link with this term or phrase 277 | internalSubdomainsLinking = 16 278 | # The number of external pages linking with this term or phrase 279 | externalPagesLinking = 32 280 | # The number of external subdomains with at least one link 281 | # with this term or phrase 282 | externalSubdomainsLinking = 64 283 | # The number of (external) root domains with at least one link 284 | # with this term or phrase 285 | externalRootDomainsLinking = 128 286 | # The amount of mozRank passed over all internal links with 287 | # this term or phrase (on the 10 point scale) 288 | internalMozRankPassed = 256 289 | # The amount of mozRank passed over all external links with 290 | # this term or phrase (on the 10 point scale) 291 | externalMozRankPassed = 512 292 | # Currently only "1" is used to indicate the term or phrase is 293 | # found in an image link 294 | flags = 1024 295 | 296 | # This is the set of all free fields 297 | freeCols = ( 298 | term | 299 | internalPagesLinking | 300 | internalSubdomainsLinking | 301 | externalPagesLinking | 302 | externalSubdomainsLinking | 303 | externalRootDomainsLinking | 304 | internalMozRankPassed | 305 | externalMozRankPassed | 306 | flags) 307 | 308 | class LinkCols: 309 | """Link Cols""" 310 | flags = 2 311 | anchorText = 4 312 | normalizedAnchorText = 8 313 | mozRankPassed = 16 314 | 315 | # The base url we request from 316 | base = 'http://lsapi.seomoz.com/linkscape/%s?%s' 317 | 318 | def __init__(self, access_id, secret_key): 319 | self.access_id = access_id 320 | self.secret_key = secret_key 321 | 322 | def signature(self, expires): 323 | to_sign = '%s\n%i' % (self.access_id, expires) 324 | return base64.b64encode( 325 | hmac.new( 326 | self.secret_key.encode('utf-8'), 327 | to_sign.encode('utf-8'), 328 | hashlib.sha1).digest()) 329 | 330 | def query(self, method, data=None, **params): 331 | expires = int(time.time() + 300) 332 | params['AccessID'] = self.access_id 333 | params['Expires'] = expires 334 | params['Signature'] = self.signature(expires) 335 | request = Mozscape.base % (method, urlencode(params)) 336 | try: 337 | reader = codecs.getreader('utf-8') 338 | return json.load(reader(urlopen(request, data))) 339 | except HTTPError as e: 340 | # The unauthorized status code can sometimes have meaningful data 341 | if e.code == 401: 342 | raise MozscapeError(e.read()) 343 | else: 344 | raise MozscapeError(e) 345 | except Exception as e: 346 | raise MozscapeError(e) 347 | 348 | def urlMetrics(self, urls, cols=UMCols.freeCols): 349 | try: 350 | basestring 351 | except NameError: 352 | basestring = str 353 | 354 | if isinstance(urls, basestring): 355 | return self.query('url-metrics/%s' % quote(urls), Cols=cols) 356 | else: 357 | return self.query( 358 | 'url-metrics', 359 | data=json.dumps(urls).encode('utf-8'), 360 | Cols=cols) 361 | 362 | def anchorText( 363 | self, url, scope='phrase_to_page', sort='domains_linking_page', 364 | cols=ATCols.freeCols): 365 | return self.query( 366 | 'anchor-text/%s' % quote(url), 367 | Scope=scope, Sort=sort, Cols=cols) 368 | 369 | def links( 370 | self, url, scope='page_to_page', sort='page_authority', 371 | filters=None, 372 | targetCols=(UMCols.url | UMCols.pageAuthority), 373 | sourceCols=(UMCols.url | UMCols.pageAuthority), 374 | linkCols=0, 375 | limit=25, 376 | offset=0): 377 | if not filters: 378 | filters = [] 379 | return self.query( 380 | 'links/%s' % quote(url), 381 | Scope=scope, 382 | Sort=sort, 383 | Filter='+'.join(filters), 384 | TargetCols=targetCols, 385 | SourceCols=sourceCols, 386 | LinkCols=linkCols, 387 | Limit=limit, 388 | Offset=offset) 389 | -------------------------------------------------------------------------------- /java/complete/src/com/seomoz/api/response/UrlResponse.java: -------------------------------------------------------------------------------- 1 | package com.seomoz.api.response; 2 | 3 | /** 4 | * 5 | * A Pojo to capture the json response from 6 | * URL Metrics 7 | * 8 | * @author Radeep Solutions 9 | */ 10 | public class UrlResponse 11 | { 12 | /** 13 | * The title of the page if available. For example: "Request-Response Format" 14 | */ 15 | private String ut; 16 | 17 | /** 18 | * The url of the page. For example: "apiwiki.seomoz.org/Request-Response+Format" 19 | */ 20 | private String uu; 21 | 22 | /** 23 | * The subdomain of the url. For example: "apiwiki.seomoz.org" 24 | */ 25 | private String ufq; 26 | 27 | /** 28 | * The root domain of the url. For example: "seomoz.org" 29 | */ 30 | private String upl; 31 | 32 | /** 33 | * The number of juice-passing external links to the url. 34 | */ 35 | private String ueid; 36 | 37 | /** 38 | * The number of juice-passing external links to the subdomain of the url. 39 | */ 40 | private String feid; 41 | 42 | /** 43 | * The number of juice-passing external links to the root domain of the url. 44 | */ 45 | private String peid; 46 | 47 | /** 48 | * The number of juice-passing links (internal or external) to the url. 49 | */ 50 | private String ujid; 51 | 52 | /** 53 | * The number of subdomains with any pages linking to the url. 54 | */ 55 | private String uifq; 56 | 57 | /** 58 | * The number of root domains with any pages linking to the url. 59 | */ 60 | private String uipl; 61 | 62 | /** 63 | * The number of links (juice-passing or not, internal or external) to the url. 64 | */ 65 | private String uid; 66 | 67 | /** 68 | * The number of subdomains with any pages linking to the subdomain of the url. 69 | */ 70 | private String fid; 71 | 72 | /** 73 | * The number of root domains with any pages linking to the root domain of the url. 74 | */ 75 | private String pid; 76 | 77 | /** 78 | * The mozRank of the url. Requesting this metric will provide both the pretty 10-point score (in umrp) and the raw score (umrr). 79 | */ 80 | private String umrp; 81 | 82 | /** 83 | * The mozRank of the url. Requesting this metric will provide both the pretty 10-point score (in umrp) and the raw score (umrr). 84 | */ 85 | private String umrr; 86 | 87 | /** 88 | * The mozRank of the subdomain of the url. Requesting this metric will provide both the pretty 10-point score (fmrp) and the raw score (fmrr). 89 | */ 90 | private String fmrp; 91 | 92 | /** 93 | * The mozRank of the subdomain of the url. Requesting this metric will provide both the pretty 10-point score (fmrp) and the raw score (fmrr). 94 | */ 95 | private String fmrr; 96 | 97 | /** 98 | * The mozRank of the Root Domain of the url. Requesting this metric will provide both the pretty 10-point score (pmrp) and the raw score (pmrr). 99 | */ 100 | private String pmrp; 101 | 102 | /** 103 | * The mozRank of the Root Domain of the url. Requesting this metric will provide both the pretty 10-point score (pmrp) and the raw score (pmrr). 104 | */ 105 | private String pmrr; 106 | 107 | /** 108 | * The mozTrust of the url. Requesting this metric will provide both the pretty 10-point score (utrp) and the raw score (utrr). 109 | */ 110 | private String utrp; 111 | 112 | /** 113 | * The mozTrust of the url. Requesting this metric will provide both the pretty 10-point score (utrp) and the raw score (utrr). 114 | */ 115 | private String utrr; 116 | 117 | /** 118 | * The mozTrust of the subdomain of the url. Requesting this metric will provide both the pretty 10-point score (ftrp) and the raw score (ftrr). 119 | */ 120 | private String ftrp; 121 | 122 | /** 123 | * The mozTrust of the subdomain of the url. Requesting this metric will provide both the pretty 10-point score (ftrp) and the raw score (ftrr). 124 | */ 125 | private String ftrr; 126 | 127 | /** 128 | * The mozTrust of the root domain of the url. Requesting this metric will provide both the pretty 10-point score (ptrp) and the raw score (ptrr). 129 | */ 130 | private String ptrp; 131 | 132 | /** 133 | * The mozTrust of the root domain of the url. Requesting this metric will provide both the pretty 10-point score (ptrp) and the raw score (ptrr). 134 | */ 135 | private String ptrr; 136 | 137 | /** 138 | * he portion of the url's mozRank coming from external links. Requesting this metric will provide both the pretty 10-point score (uemrp) and the raw score (uemrr). 139 | */ 140 | private String uemrp; 141 | 142 | /** 143 | * he portion of the url's mozRank coming from external links. Requesting this metric will provide both the pretty 10-point score (uemrp) and the raw score (uemrr). 144 | */ 145 | private String uemrr; 146 | 147 | /** 148 | * The portion of the mozRank of all pages on the subdomain coming from external links. Requesting this metric will provide both the pretty 10-point score (fejp) and the raw score (fejr). 149 | */ 150 | private String fejp; 151 | 152 | /** 153 | * The portion of the mozRank of all pages on the subdomain coming from external links. Requesting this metric will provide both the pretty 10-point score (fejp) and the raw score (fejr). 154 | */ 155 | private String fejr; 156 | 157 | /** 158 | * The portion of the mozRank of all pages on the root domain coming from external links. Requesting this metric will provide both the pretty 10-point score (pejp) and the raw score (pejr). 159 | */ 160 | private String pejp; 161 | 162 | /** 163 | * The portion of the mozRank of all pages on the root domain coming from external links. Requesting this metric will provide both the pretty 10-point score (pejp) and the raw score (pejr). 164 | */ 165 | private String pejr; 166 | 167 | /** 168 | * The mozRank of all pages on the subdomain combined. Requesting this metric will provide both the pretty 10-point score (fjp) and the raw score (fjr). 169 | */ 170 | private String fjp; 171 | 172 | /** 173 | * The mozRank of all pages on the subdomain combined. Requesting this metric will provide both the pretty 10-point score (fjp) and the raw score (fjr). 174 | */ 175 | private String fjr; 176 | 177 | /** 178 | * The mozRank of all pages on the root domain combined. Requesting this metric will provide both the pretty 10-point score (pjp) and the raw score (pjr). 179 | */ 180 | private String pjp; 181 | 182 | /** 183 | * The mozRank of all pages on the root domain combined. Requesting this metric will provide both the pretty 10-point score (pjp) and the raw score (pjr). 184 | */ 185 | private String pjr; 186 | 187 | /** 188 | * If the url canaonicalizes to a different form, that canonical form will be available in this field. 189 | */ 190 | private String ur; 191 | 192 | /** 193 | * The HTTP status code recorded by Linkscape for this URL (if available) 194 | */ 195 | private String us; 196 | 197 | /** 198 | * Total links (including internal and nofollow links) to the subdomain of the url in question. 199 | */ 200 | private String fuid; 201 | 202 | /** 203 | * Total links (including internal and nofollow links) to the root domain of the url in question. 204 | */ 205 | private String puid; 206 | 207 | /** 208 | * The number of root domains with at least one link to the subdomain of the url in question. 209 | */ 210 | private String fipl; 211 | 212 | /** 213 | * A score out of 100-points representing the likelihood for arbitrary content to rank on this page 214 | */ 215 | private String upa; 216 | 217 | /** 218 | * A score out of 100-points representing the likelihood for arbitrary content to rank on this dom 219 | */ 220 | private String pda; 221 | 222 | /** 223 | * @return the fmrp 224 | */ 225 | public String getFmrp() { 226 | return fmrp; 227 | } 228 | /** 229 | * @param fmrp the fmrp to set 230 | */ 231 | public void setFmrp(String fmrp) { 232 | this.fmrp = fmrp; 233 | } 234 | /** 235 | * @return the fmrr 236 | */ 237 | public String getFmrr() { 238 | return fmrr; 239 | } 240 | /** 241 | * @param fmrr the fmrr to set 242 | */ 243 | public void setFmrr(String fmrr) { 244 | this.fmrr = fmrr; 245 | } 246 | /** 247 | * @return the pda 248 | */ 249 | public String getPda() { 250 | return pda; 251 | } 252 | /** 253 | * @param pda the pda to set 254 | */ 255 | public void setPda(String pda) { 256 | this.pda = pda; 257 | } 258 | /** 259 | * @return the ueid 260 | */ 261 | public String getUeid() { 262 | return ueid; 263 | } 264 | /** 265 | * @param ueid the ueid to set 266 | */ 267 | public void setUeid(String ueid) { 268 | this.ueid = ueid; 269 | } 270 | /** 271 | * @return the ufq 272 | */ 273 | public String getUfq() { 274 | return ufq; 275 | } 276 | /** 277 | * @param ufq the ufq to set 278 | */ 279 | public void setUfq(String ufq) { 280 | this.ufq = ufq; 281 | } 282 | /** 283 | * @return the uid 284 | */ 285 | public String getUid() { 286 | return uid; 287 | } 288 | /** 289 | * @param uid the uid to set 290 | */ 291 | public void setUid(String uid) { 292 | this.uid = uid; 293 | } 294 | /** 295 | * @return the umrp 296 | */ 297 | public String getUmrp() { 298 | return umrp; 299 | } 300 | /** 301 | * @param umrp the umrp to set 302 | */ 303 | public void setUmrp(String umrp) { 304 | this.umrp = umrp; 305 | } 306 | /** 307 | * @return the umrr 308 | */ 309 | public String getUmrr() { 310 | return umrr; 311 | } 312 | /** 313 | * @param umrr the umrr to set 314 | */ 315 | public void setUmrr(String umrr) { 316 | this.umrr = umrr; 317 | } 318 | /** 319 | * @return the upa 320 | */ 321 | public String getUpa() { 322 | return upa; 323 | } 324 | /** 325 | * @param upa the upa to set 326 | */ 327 | public void setUpa(String upa) { 328 | this.upa = upa; 329 | } 330 | /** 331 | * @return the upl 332 | */ 333 | public String getUpl() { 334 | return upl; 335 | } 336 | /** 337 | * @param upl the upl to set 338 | */ 339 | public void setUpl(String upl) { 340 | this.upl = upl; 341 | } 342 | /** 343 | * @return the us 344 | */ 345 | public String getUs() { 346 | return us; 347 | } 348 | /** 349 | * @param us the us to set 350 | */ 351 | public void setUs(String us) { 352 | this.us = us; 353 | } 354 | /** 355 | * @return the ut 356 | */ 357 | public String getUt() { 358 | return ut; 359 | } 360 | /** 361 | * @param ut the ut to set 362 | */ 363 | public void setUt(String ut) { 364 | this.ut = ut; 365 | } 366 | /** 367 | * @return the uu 368 | */ 369 | public String getUu() { 370 | return uu; 371 | } 372 | /** 373 | * @param uu the uu to set 374 | */ 375 | public void setUu(String uu) { 376 | this.uu = uu; 377 | } 378 | /** 379 | * @return the feid 380 | */ 381 | public String getFeid() { 382 | return feid; 383 | } 384 | /** 385 | * @param feid the feid to set 386 | */ 387 | public void setFeid(String feid) { 388 | this.feid = feid; 389 | } 390 | /** 391 | * @return the peid 392 | */ 393 | public String getPeid() { 394 | return peid; 395 | } 396 | /** 397 | * @param peid the peid to set 398 | */ 399 | public void setPeid(String peid) { 400 | this.peid = peid; 401 | } 402 | /** 403 | * @return the ujid 404 | */ 405 | public String getUjid() { 406 | return ujid; 407 | } 408 | /** 409 | * @param ujid the ujid to set 410 | */ 411 | public void setUjid(String ujid) { 412 | this.ujid = ujid; 413 | } 414 | /** 415 | * @return the uifq 416 | */ 417 | public String getUifq() { 418 | return uifq; 419 | } 420 | /** 421 | * @param uifq the uifq to set 422 | */ 423 | public void setUifq(String uifq) { 424 | this.uifq = uifq; 425 | } 426 | /** 427 | * @return the uipl 428 | */ 429 | public String getUipl() { 430 | return uipl; 431 | } 432 | /** 433 | * @param uipl the uipl to set 434 | */ 435 | public void setUipl(String uipl) { 436 | this.uipl = uipl; 437 | } 438 | /** 439 | * @return the fid 440 | */ 441 | public String getFid() { 442 | return fid; 443 | } 444 | /** 445 | * @param fid the fid to set 446 | */ 447 | public void setFid(String fid) { 448 | this.fid = fid; 449 | } 450 | /** 451 | * @return the pid 452 | */ 453 | public String getPid() { 454 | return pid; 455 | } 456 | /** 457 | * @param pid the pid to set 458 | */ 459 | public void setPid(String pid) { 460 | this.pid = pid; 461 | } 462 | /** 463 | * @return the pmrp 464 | */ 465 | public String getPmrp() { 466 | return pmrp; 467 | } 468 | /** 469 | * @param pmrp the pmrp to set 470 | */ 471 | public void setPmrp(String pmrp) { 472 | this.pmrp = pmrp; 473 | } 474 | /** 475 | * @return the pmrr 476 | */ 477 | public String getPmrr() { 478 | return pmrr; 479 | } 480 | /** 481 | * @param pmrr the pmrr to set 482 | */ 483 | public void setPmrr(String pmrr) { 484 | this.pmrr = pmrr; 485 | } 486 | /** 487 | * @return the utrp 488 | */ 489 | public String getUtrp() { 490 | return utrp; 491 | } 492 | /** 493 | * @param utrp the utrp to set 494 | */ 495 | public void setUtrp(String utrp) { 496 | this.utrp = utrp; 497 | } 498 | /** 499 | * @return the utrr 500 | */ 501 | public String getUtrr() { 502 | return utrr; 503 | } 504 | /** 505 | * @param utrr the utrr to set 506 | */ 507 | public void setUtrr(String utrr) { 508 | this.utrr = utrr; 509 | } 510 | /** 511 | * @return the ftrp 512 | */ 513 | public String getFtrp() { 514 | return ftrp; 515 | } 516 | /** 517 | * @param ftrp the ftrp to set 518 | */ 519 | public void setFtrp(String ftrp) { 520 | this.ftrp = ftrp; 521 | } 522 | /** 523 | * @return the ftrr 524 | */ 525 | public String getFtrr() { 526 | return ftrr; 527 | } 528 | /** 529 | * @param ftrr the ftrr to set 530 | */ 531 | public void setFtrr(String ftrr) { 532 | this.ftrr = ftrr; 533 | } 534 | /** 535 | * @return the ptrp 536 | */ 537 | public String getPtrp() { 538 | return ptrp; 539 | } 540 | /** 541 | * @param ptrp the ptrp to set 542 | */ 543 | public void setPtrp(String ptrp) { 544 | this.ptrp = ptrp; 545 | } 546 | /** 547 | * @return the ptrr 548 | */ 549 | public String getPtrr() { 550 | return ptrr; 551 | } 552 | /** 553 | * @param ptrr the ptrr to set 554 | */ 555 | public void setPtrr(String ptrr) { 556 | this.ptrr = ptrr; 557 | } 558 | /** 559 | * @return the uemrp 560 | */ 561 | public String getUemrp() { 562 | return uemrp; 563 | } 564 | /** 565 | * @param uemrp the uemrp to set 566 | */ 567 | public void setUemrp(String uemrp) { 568 | this.uemrp = uemrp; 569 | } 570 | /** 571 | * @return the uemrr 572 | */ 573 | public String getUemrr() { 574 | return uemrr; 575 | } 576 | /** 577 | * @param uemrr the uemrr to set 578 | */ 579 | public void setUemrr(String uemrr) { 580 | this.uemrr = uemrr; 581 | } 582 | /** 583 | * @return the fejp 584 | */ 585 | public String getFejp() { 586 | return fejp; 587 | } 588 | /** 589 | * @param fejp the fejp to set 590 | */ 591 | public void setFejp(String fejp) { 592 | this.fejp = fejp; 593 | } 594 | /** 595 | * @return the fejr 596 | */ 597 | public String getFejr() { 598 | return fejr; 599 | } 600 | /** 601 | * @param fejr the fejr to set 602 | */ 603 | public void setFejr(String fejr) { 604 | this.fejr = fejr; 605 | } 606 | /** 607 | * @return the pejp 608 | */ 609 | public String getPejp() { 610 | return pejp; 611 | } 612 | /** 613 | * @param pejp the pejp to set 614 | */ 615 | public void setPejp(String pejp) { 616 | this.pejp = pejp; 617 | } 618 | /** 619 | * @return the pejr 620 | */ 621 | public String getPejr() { 622 | return pejr; 623 | } 624 | /** 625 | * @param pejr the pejr to set 626 | */ 627 | public void setPejr(String pejr) { 628 | this.pejr = pejr; 629 | } 630 | /** 631 | * @return the fjp 632 | */ 633 | public String getFjp() { 634 | return fjp; 635 | } 636 | /** 637 | * @param fjp the fjp to set 638 | */ 639 | public void setFjp(String fjp) { 640 | this.fjp = fjp; 641 | } 642 | /** 643 | * @return the fjr 644 | */ 645 | public String getFjr() { 646 | return fjr; 647 | } 648 | /** 649 | * @param fjr the fjr to set 650 | */ 651 | public void setFjr(String fjr) { 652 | this.fjr = fjr; 653 | } 654 | /** 655 | * @return the pjp 656 | */ 657 | public String getPjp() { 658 | return pjp; 659 | } 660 | /** 661 | * @param pjp the pjp to set 662 | */ 663 | public void setPjp(String pjp) { 664 | this.pjp = pjp; 665 | } 666 | /** 667 | * @return the pjr 668 | */ 669 | public String getPjr() { 670 | return pjr; 671 | } 672 | /** 673 | * @param pjr the pjr to set 674 | */ 675 | public void setPjr(String pjr) { 676 | this.pjr = pjr; 677 | } 678 | /** 679 | * @return the ur 680 | */ 681 | public String getUr() { 682 | return ur; 683 | } 684 | /** 685 | * @param ur the ur to set 686 | */ 687 | public void setUr(String ur) { 688 | this.ur = ur; 689 | } 690 | /** 691 | * @return the fuid 692 | */ 693 | public String getFuid() { 694 | return fuid; 695 | } 696 | /** 697 | * @param fuid the fuid to set 698 | */ 699 | public void setFuid(String fuid) { 700 | this.fuid = fuid; 701 | } 702 | /** 703 | * @return the puid 704 | */ 705 | public String getPuid() { 706 | return puid; 707 | } 708 | /** 709 | * @param puid the puid to set 710 | */ 711 | public void setPuid(String puid) { 712 | this.puid = puid; 713 | } 714 | /** 715 | * @return the fipl 716 | */ 717 | public String getFipl() { 718 | return fipl; 719 | } 720 | /** 721 | * @param fipl the fipl to set 722 | */ 723 | public void setFipl(String fipl) { 724 | this.fipl = fipl; 725 | } 726 | 727 | /* (non-Javadoc) 728 | * @see java.lang.Object#toString() 729 | */ 730 | public String toString() { 731 | return "Response [feid=" + feid + ", fejp=" + fejp + ", fejr=" + fejr 732 | + ", fid=" + fid + ", fipl=" + fipl + ", fjp=" + fjp + ", fjr=" 733 | + fjr + ", fmrp=" + fmrp + ", fmrr=" + fmrr + ", ftrp=" + ftrp 734 | + ", ftrr=" + ftrr + ", fuid=" + fuid + ", pda=" + pda 735 | + ", peid=" + peid + ", pejp=" + pejp + ", pejr=" + pejr 736 | + ", pid=" + pid + ", pjp=" + pjp + ", pjr=" + pjr + ", pmrp=" 737 | + pmrp + ", pmrr=" + pmrr + ", ptrp=" + ptrp + ", ptrr=" + ptrr 738 | + ", puid=" + puid + ", ueid=" + ueid + ", uemrp=" + uemrp 739 | + ", uemrr=" + uemrr + ", ufq=" + ufq + ", uid=" + uid 740 | + ", uifq=" + uifq + ", uipl=" + uipl + ", ujid=" + ujid 741 | + ", umrp=" + umrp + ", umrr=" + umrr + ", upa=" + upa 742 | + ", upl=" + upl + ", ur=" + ur + ", us=" + us + ", ut=" + ut 743 | + ", utrp=" + utrp + ", utrr=" + utrr + ", uu=" + uu + "]"; 744 | } 745 | 746 | 747 | } 748 | --------------------------------------------------------------------------------