├── .gitattributes ├── .github └── workflows │ └── dotnetcore.yml ├── .gitignore ├── BuiltWith.sln ├── BuiltWith ├── BuiltWith.cs ├── BuiltWith.csproj ├── Client │ ├── BuiltWithRestClient.cs │ └── IBuiltWithRestClient.cs ├── Exceptions │ ├── APIConnectionException.cs │ └── BuiltWithException.cs ├── Http │ ├── BasicHttpClient.cs │ ├── HttpClient.cs │ ├── Request.cs │ └── Response.cs ├── Objects │ └── v14 │ │ └── JSON.cs └── newLogoSquare.png ├── BuiltWithTest ├── BuiltWithTest.csproj └── DomainAPITest.cs └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/dotnetcore.yml: -------------------------------------------------------------------------------- 1 | name: .NET Core 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Setup .NET Core 13 | uses: actions/setup-dotnet@v1 14 | with: 15 | dotnet-version: 2.2.108 16 | - name: Build with dotnet 17 | run: dotnet build --configuration Release 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /BuiltWith.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29728.190 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuiltWith", "BuiltWith\BuiltWith.csproj", "{882657FC-8E0D-40EE-8311-844DAE0B9B45}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuiltWithTest", "BuiltWithTest\BuiltWithTest.csproj", "{38341BE4-8A12-431A-9A6F-92EA7BF7CC3D}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClientAPI", "ClientAPI", "{6C67EB9E-2DAE-447E-BC1C-8703D7FE3F92}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9072CB14-1724-433F-9740-88D88CA980A3}" 13 | ProjectSection(SolutionItems) = preProject 14 | README.md = README.md 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {882657FC-8E0D-40EE-8311-844DAE0B9B45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {882657FC-8E0D-40EE-8311-844DAE0B9B45}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {882657FC-8E0D-40EE-8311-844DAE0B9B45}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {882657FC-8E0D-40EE-8311-844DAE0B9B45}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {38341BE4-8A12-431A-9A6F-92EA7BF7CC3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {38341BE4-8A12-431A-9A6F-92EA7BF7CC3D}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {38341BE4-8A12-431A-9A6F-92EA7BF7CC3D}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {38341BE4-8A12-431A-9A6F-92EA7BF7CC3D}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(NestedProjects) = preSolution 36 | {882657FC-8E0D-40EE-8311-844DAE0B9B45} = {6C67EB9E-2DAE-447E-BC1C-8703D7FE3F92} 37 | {38341BE4-8A12-431A-9A6F-92EA7BF7CC3D} = {6C67EB9E-2DAE-447E-BC1C-8703D7FE3F92} 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {927D142D-5AA1-4284-892A-2649F448F058} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /BuiltWith/BuiltWith.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace BuiltWith 7 | { 8 | 9 | public class BuiltWithClient 10 | { 11 | 12 | private static string _key; 13 | private static Client.BuiltWithRestClient _restClient; 14 | 15 | 16 | public static void Init ( string apiKey ) 17 | { 18 | _key = apiKey; 19 | if ( string.IsNullOrEmpty ( _key ) ) throw new Exceptions.BuiltWithException ( "Key cannot be blank or null" ); 20 | } 21 | 22 | public static void Init ( Guid apiKey ) 23 | { 24 | _key = apiKey.ToString ( ); 25 | if ( string.IsNullOrEmpty ( _key ) ) throw new Exceptions.BuiltWithException ( "Key cannot be blank or null" ); 26 | } 27 | 28 | 29 | private static Client.BuiltWithRestClient _getRestClient ( ) 30 | { 31 | if ( _restClient != null ) 32 | { 33 | return _restClient; 34 | } 35 | 36 | if ( string.IsNullOrEmpty ( _key ) ) 37 | { 38 | throw new Exceptions.BuiltWithException ( "No API Key - call BuiltWithClient.Init(\"your api key\"); first" ); 39 | } 40 | 41 | _restClient = new Client.BuiltWithRestClient ( _key ); 42 | return _restClient; 43 | 44 | } 45 | 46 | 47 | public static Objects.v14.DomainAPI GetDomain ( params string[] domain ) 48 | { 49 | 50 | if ( string.IsNullOrEmpty ( _key ) ) throw new Exceptions.BuiltWithException ( "No API Key - call BuiltWithClient.Init(\"your api key\"); first" ); 51 | 52 | if ( domain.Length > 16 ) 53 | { 54 | throw new Exceptions.BuiltWithException ( "Maximum 16 domains at a time." ); 55 | } 56 | 57 | List> @params = new List> ( ); 58 | @params.Add ( new KeyValuePair ( "KEY" , _key ) ); 59 | @params.Add ( new KeyValuePair ( "LOOKUP" , string.Join(",",domain) ) ); 60 | System.Threading.Tasks.Task task = _getRestClient ( ).HttpClient.MakeRequestAsync ( new Http.Request ( "https://api.builtwith.com/v15/api.json" , @params ) ); 61 | task.Wait ( ); 62 | 63 | if ( task.Result != null && task.Result.StatusCode == System.Net.HttpStatusCode.OK ) 64 | { 65 | return Objects.v14.DomainAPI.FromJson ( task.Result.Content ); 66 | } 67 | else 68 | { 69 | throw new Exceptions.APIConnectionException ( "API Error: " + ( task.Result == null ? "Result is NULL" : "Status code - " + task.Result.StatusCode ) ); 70 | } 71 | 72 | 73 | } 74 | 75 | 76 | 77 | public static Objects.v14.DomainAPI GetDomain ( string domain ) 78 | { 79 | if ( string.IsNullOrEmpty ( _key ) ) throw new Exceptions.BuiltWithException ( "No API Key - call BuiltWithClient.Init(\"your api key\"); first" ); 80 | 81 | 82 | List> @params = new List> ( ); 83 | @params.Add ( new KeyValuePair ( "KEY" , _key ) ); 84 | @params.Add ( new KeyValuePair ( "LOOKUP" , domain ) ); 85 | System.Threading.Tasks.Task task = _getRestClient ( ).HttpClient.MakeRequestAsync ( new Http.Request ( "https://api.builtwith.com/v14/api.json" , @params ) ); 86 | task.Wait ( ); 87 | 88 | if ( task.Result != null && task.Result.StatusCode == System.Net.HttpStatusCode.OK ) 89 | { 90 | return Objects.v14.DomainAPI.FromJson ( task.Result.Content ); 91 | } 92 | else 93 | { 94 | throw new Exceptions.APIConnectionException ( "API Error: " + ( task.Result == null ? "Result is NULL" : "Status code - " + task.Result.StatusCode ) ); 95 | } 96 | 97 | 98 | } 99 | 100 | 101 | 102 | 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /BuiltWith/BuiltWith.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 70b08464-4670-4cc2-8c77-da2837b41e1f 8 | true 9 | Gary Brewer 10 | BuiltWith Pty Ltd 11 | REST Client SDK for the BuiltWith.com API 12 | Copyright (c) BuiltWith Pty Ltd 13 | MIT 14 | https://github.com/builtwith/BuiltWith-C-Client-API 15 | newLogoSquare.png 16 | 17 | https://github.com/builtwith/BuiltWith-C-Client-API 18 | 1.0.0.1 19 | 1.0.0.1 20 | 1.0.1 21 | 22 | 23 | 24 | x64 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | True 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /BuiltWith/Client/BuiltWithRestClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Text; 5 | 6 | namespace BuiltWith.Client 7 | { 8 | public class BuiltWithRestClient 9 | { 10 | public string ApiKey { get; } 11 | 12 | public Http.HttpClient HttpClient { get; } 13 | 14 | public BuiltWithRestClient ( string apiKey , Http.HttpClient client = null ) 15 | { 16 | ApiKey = apiKey; 17 | HttpClient = client ?? new Http.BasicHttpClient ( ); 18 | } 19 | 20 | 21 | public Http.Response Request ( Http.Request request ) 22 | { 23 | request.SetKey ( ApiKey ); 24 | Http.Response response; 25 | try 26 | { 27 | response = HttpClient.MakeRequest ( request ); 28 | } 29 | catch ( Exception clientException ) 30 | { 31 | throw new Exceptions.APIConnectionException ( 32 | "Connection Error: " + request.ConstructUrl ( ) , 33 | clientException 34 | ); 35 | } 36 | return ProcessResponse ( response ); 37 | } 38 | 39 | 40 | private static Http.Response ProcessResponse ( Http.Response response ) 41 | { 42 | if ( response == null ) 43 | { 44 | throw new Exceptions.APIConnectionException ( "Connection Error: No response received." ); 45 | } 46 | 47 | if ( response.StatusCode == HttpStatusCode.OK ) return response; 48 | else throw new Exceptions.APIConnectionException ( "Connection Error: Status Code - " + response.StatusCode ); 49 | 50 | } 51 | } 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /BuiltWith/Client/IBuiltWithRestClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BuiltWith.Client 6 | { 7 | public interface IBuiltWithRestClient 8 | { 9 | string ApiKey { get; } 10 | 11 | Http.HttpClient HttpClient { get; } 12 | 13 | Http.Response Request ( Http.Request request ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BuiltWith/Exceptions/APIConnectionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BuiltWith.Exceptions 6 | { 7 | public class APIConnectionException : BuiltWithException 8 | { 9 | public APIConnectionException ( string message ) : base ( message ) { } 10 | 11 | public APIConnectionException ( string message , Exception exception ) : base ( message , exception ) { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BuiltWith/Exceptions/BuiltWithException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BuiltWith.Exceptions 6 | { 7 | public class BuiltWithException : Exception 8 | { 9 | 10 | public BuiltWithException ( string message ) : base ( message ) { } 11 | 12 | public BuiltWithException ( ) : base ( ) { } 13 | 14 | public BuiltWithException ( string message , Exception exception ) : base ( message , exception ) { } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BuiltWith/Http/BasicHttpClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Net.Http; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace BuiltWith.Http 9 | { 10 | public class BasicHttpClient : HttpClient 11 | { 12 | 13 | public BasicHttpClient ( System.Net.Http.HttpClient httpClient = null ) 14 | { 15 | _httpClient = httpClient ?? new System.Net.Http.HttpClient ( ); 16 | } 17 | 18 | 19 | private readonly System.Net.Http.HttpClient _httpClient; 20 | public override Response MakeRequest ( Request request ) 21 | { 22 | try 23 | { 24 | var task = MakeRequestAsync ( request ); 25 | task.Wait ( ); 26 | return task.Result; 27 | } 28 | catch ( AggregateException ae ) 29 | { 30 | // Combine nested AggregateExceptions 31 | ae = ae.Flatten ( ); 32 | throw ae.InnerExceptions [ 0 ]; 33 | } 34 | } 35 | 36 | public override async Task MakeRequestAsync ( Request request ) 37 | { 38 | var httpRequest = BuildHttpRequest ( request ); 39 | 40 | 41 | var httpResponse = await _httpClient.SendAsync ( httpRequest ).ConfigureAwait ( false ); 42 | var reader = new StreamReader ( await httpResponse.Content.ReadAsStreamAsync ( ).ConfigureAwait ( false ) ); 43 | 44 | // Create and return a new Response. Keep a reference to the last 45 | // response for debugging, but don't return it as it may be shared 46 | // among threads. 47 | var response = new Response ( httpResponse.StatusCode , await reader.ReadToEndAsync ( ).ConfigureAwait ( false ) ); 48 | return response; 49 | } 50 | 51 | 52 | 53 | 54 | 55 | private HttpRequestMessage BuildHttpRequest ( Request request ) 56 | { 57 | var httpRequest = new HttpRequestMessage ( 58 | new System.Net.Http.HttpMethod ("GET") , 59 | request.ConstructUrl ( ) 60 | ); 61 | 62 | httpRequest.Headers.TryAddWithoutValidation ( "User-Agent" , "builtwith-csharp-lib" ); 63 | 64 | return httpRequest; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /BuiltWith/Http/HttpClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BuiltWith.Http 6 | { 7 | public abstract class HttpClient 8 | { 9 | public abstract Response MakeRequest ( Request request ); 10 | 11 | public abstract System.Threading.Tasks.Task MakeRequestAsync ( Request request ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BuiltWith/Http/Request.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Text; 5 | 6 | namespace BuiltWith.Http 7 | { 8 | public class Request 9 | { 10 | public string ApiKey; 11 | 12 | private readonly Uri _uri; 13 | private readonly List> _queryParams; 14 | 15 | 16 | public Uri ConstructUrl ( ) 17 | { 18 | return _queryParams.Count > 0 ? 19 | new Uri ( _uri.AbsoluteUri + "?" + EncodeParameters ( _queryParams ) ) : 20 | new Uri ( _uri.AbsoluteUri ); 21 | } 22 | 23 | private static string EncodeParameters ( IEnumerable> data ) 24 | { 25 | var result = ""; 26 | var first = true; 27 | foreach ( var pair in data ) 28 | { 29 | if ( first ) 30 | { 31 | first = false; 32 | } 33 | else 34 | { 35 | result += "&"; 36 | } 37 | 38 | result += WebUtility.UrlEncode ( pair.Key ) + "=" + WebUtility.UrlEncode ( pair.Value ); 39 | 40 | } 41 | 42 | return result; 43 | } 44 | 45 | public Request ( string baseUrl, List> queryParams = null ) 46 | { 47 | _uri = new Uri ( baseUrl ); 48 | _queryParams = queryParams ?? new List> ( ); 49 | } 50 | 51 | public void SetKey ( string apiKey ) 52 | { 53 | ApiKey = apiKey; 54 | } 55 | 56 | 57 | public void AddQueryParam ( string name , string value ) 58 | { 59 | AddParam ( _queryParams , name , value ); 60 | } 61 | 62 | private static void AddParam ( ICollection> list , string name , string value ) 63 | { 64 | list.Add ( new KeyValuePair ( name , value ) ); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /BuiltWith/Http/Response.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Text; 5 | 6 | namespace BuiltWith.Http 7 | { 8 | public class Response 9 | { 10 | public HttpStatusCode StatusCode { get; } 11 | 12 | public string Content { get; } 13 | 14 | public Response ( HttpStatusCode statusCode , string content ) 15 | { 16 | StatusCode = statusCode; 17 | Content = content; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /BuiltWith/Objects/v14/JSON.cs: -------------------------------------------------------------------------------- 1 | namespace BuiltWith.Objects.v14 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using System.Globalization; 7 | using Newtonsoft.Json; 8 | using Newtonsoft.Json.Converters; 9 | using J = Newtonsoft.Json.JsonPropertyAttribute; 10 | using R = Newtonsoft.Json.Required; 11 | using N = Newtonsoft.Json.NullValueHandling; 12 | 13 | 14 | public partial class DomainAPI 15 | { 16 | public static DomainAPI FromJson ( string json ) => JsonConvert.DeserializeObject ( json , BuiltWith.Objects.v14.Converter.Settings ); 17 | } 18 | 19 | public partial class DomainAPI 20 | { 21 | [J ( "Results" )] public ResultElement [ ] Results { get; set; } 22 | [J ( "Errors" )] public object [ ] Errors { get; set; } 23 | } 24 | 25 | public partial class ResultElement 26 | { 27 | [J ( "Result" )] public ResultResult Result { get; set; } 28 | [J ( "Meta" )] public Meta Meta { get; set; } 29 | [J ( "Attributes" )] public Dictionary Attributes { get; set; } 30 | [J ( "FirstIndexed" )] public long FirstIndexed { get; set; } 31 | [J ( "LastIndexed" )] public long LastIndexed { get; set; } 32 | [J ( "Lookup" )] public string Lookup { get; set; } 33 | } 34 | 35 | public partial class Meta 36 | { 37 | [J ( "Majestic" )] public long Majestic { get; set; } 38 | [J ( "Umbrella" )] public long Umbrella { get; set; } 39 | [J ( "Vertical" )] public string Vertical { get; set; } 40 | [J ( "Social" )] public Uri [ ] Social { get; set; } 41 | [J ( "CompanyName" )] public string CompanyName { get; set; } 42 | [J ( "Telephones" )] public string [ ] Telephones { get; set; } 43 | [J ( "Emails" )] public object [ ] Emails { get; set; } 44 | [J ( "City" )] public string City { get; set; } 45 | [J ( "State" )] public string State { get; set; } 46 | [J ( "Postcode" )] public string Postcode { get; set; } 47 | [J ( "Country" )] public string Country { get; set; } 48 | [J ( "Names" )] public Name [ ] Names { get; set; } 49 | [J ( "ARank" )] public long ARank { get; set; } 50 | [J ( "QRank" )] public long QRank { get; set; } 51 | } 52 | 53 | public partial class Name 54 | { 55 | [J ( "Name" )] public string NameName { get; set; } 56 | [J ( "Type" )] public long Type { get; set; } 57 | [J ( "Email" )] public string Email { get; set; } 58 | } 59 | 60 | public partial class ResultResult 61 | { 62 | [J ( "IsDB" )] public string IsDb { get; set; } 63 | [J ( "Spend" )] public long Spend { get; set; } 64 | [J ( "Paths" )] public Path [ ] Paths { get; set; } 65 | } 66 | 67 | public partial class Path 68 | { 69 | [J ( "FirstIndexed" )] public long FirstIndexed { get; set; } 70 | [J ( "LastIndexed" )] public long LastIndexed { get; set; } 71 | [J ( "Domain" )] public string Domain { get; set; } 72 | [J ( "Url" )] public string Url { get; set; } 73 | [J ( "SubDomain" )] public string SubDomain { get; set; } 74 | [J ( "Technologies" )] public Technology [ ] Technologies { get; set; } 75 | } 76 | 77 | public partial class Technology 78 | { 79 | [J ( "Categories" )] public string [ ] Categories { get; set; } 80 | [J ( "IsPremium" )] public IsPremium IsPremium { get; set; } 81 | [J ( "Name" )] public string Name { get; set; } 82 | [J ( "Description" )] public string Description { get; set; } 83 | [J ( "Link" )] public Uri Link { get; set; } 84 | [J ( "Tag" )] public string Tag { get; set; } 85 | [J ( "FirstDetected" )] public long FirstDetected { get; set; } 86 | [J ( "LastDetected" )] public long LastDetected { get; set; } 87 | } 88 | 89 | 90 | public enum IsPremium { Maybe, No, Yes }; 91 | 92 | 93 | internal static class Converter 94 | { 95 | public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings 96 | { 97 | MetadataPropertyHandling = MetadataPropertyHandling.Ignore , 98 | DateParseHandling = DateParseHandling.None , 99 | Converters = 100 | { 101 | IsPremiumConverter.Singleton, 102 | 103 | new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal } 104 | } , 105 | }; 106 | } 107 | 108 | 109 | 110 | 111 | 112 | internal class IsPremiumConverter : JsonConverter 113 | { 114 | public override bool CanConvert ( Type t ) => t == typeof ( IsPremium ) || t == typeof ( IsPremium? ); 115 | 116 | public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer ) 117 | { 118 | if ( reader.TokenType == JsonToken.Null ) return null; 119 | var value = serializer.Deserialize ( reader ); 120 | switch ( value ) 121 | { 122 | case "maybe": 123 | return IsPremium.Maybe; 124 | case "no": 125 | return IsPremium.No; 126 | case "yes": 127 | return IsPremium.Yes; 128 | } 129 | throw new Exception ( "Cannot unmarshal type IsPremium" ); 130 | } 131 | 132 | public override void WriteJson ( JsonWriter writer , object untypedValue , JsonSerializer serializer ) 133 | { 134 | if ( untypedValue == null ) 135 | { 136 | serializer.Serialize ( writer , null ); 137 | return; 138 | } 139 | var value = ( IsPremium ) untypedValue; 140 | switch ( value ) 141 | { 142 | case IsPremium.Maybe: 143 | serializer.Serialize ( writer , "maybe" ); 144 | return; 145 | case IsPremium.No: 146 | serializer.Serialize ( writer , "no" ); 147 | return; 148 | case IsPremium.Yes: 149 | serializer.Serialize ( writer , "yes" ); 150 | return; 151 | } 152 | throw new Exception ( "Cannot marshal type IsPremium" ); 153 | } 154 | 155 | public static readonly IsPremiumConverter Singleton = new IsPremiumConverter ( ); 156 | } 157 | 158 | 159 | } 160 | -------------------------------------------------------------------------------- /BuiltWith/newLogoSquare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/builtwith/BuiltWith-C-Client-API/465bec7e7428acf3f77643418fee7893dc5529e9/BuiltWith/newLogoSquare.png -------------------------------------------------------------------------------- /BuiltWithTest/BuiltWithTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /BuiltWithTest/DomainAPITest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace BuiltWithTest 4 | { 5 | [TestClass] 6 | public class DomainAPITest 7 | { 8 | 9 | 10 | 11 | 12 | 13 | 14 | public const string APIKEY = "ENTER YOUR API KEY HERE FOUND AT https://api.builtwith.com"; 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | // This needs to be run alone it will fail if all tests are run at once. 23 | [TestMethod] 24 | [ExpectedException ( typeof ( BuiltWith.Exceptions.BuiltWithException ) )] 25 | public void _NoAPIKey ( ) 26 | { 27 | BuiltWith.BuiltWithClient.GetDomain ( "builtwith.com" ); 28 | } 29 | 30 | 31 | [ TestMethod] 32 | public void DomainAPISingle ( ) 33 | { 34 | BuiltWith.BuiltWithClient.Init ( APIKEY ); 35 | BuiltWith.Objects.v14.DomainAPI domain = BuiltWith.BuiltWithClient.GetDomain ( "builtwith.com" ); 36 | Assert.IsTrue ( domain != null && domain.Results != null && domain.Results.Length == 1 && domain.Results [ 0 ].Result.IsDb.Equals("True") ); 37 | } 38 | 39 | 40 | 41 | [TestMethod] 42 | 43 | public void DomainAPIMulti ( ) 44 | { 45 | BuiltWith.BuiltWithClient.Init ( APIKEY ); 46 | BuiltWith.Objects.v14.DomainAPI domain = BuiltWith.BuiltWithClient.GetDomain ( "builtwith.com","overstock.com" ); 47 | Assert.IsTrue ( domain != null && domain.Results != null && domain.Results.Length ==2 && domain.Results [ 0 ].Result.IsDb.Equals ( "True" ) && domain.Results [ 1 ].Result.IsDb.Equals ( "True" ) ); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BuiltWith C# Client SDK 2 | 3 | Provides a C# client SDK providing functions to access the BuiltWith API. ![.NET Core](https://github.com/builtwith/BuiltWith-C-Client-API/workflows/.NET%20Core/badge.svg?branch=master) 4 | 5 | ## Getting Started 6 | 7 | ``` 8 | BuiltWith.BuiltWithClient.Init ( "YOUR_API_KEY" ); 9 | BuiltWith.Objects.v14.DomainAPI domain = BuiltWith.BuiltWithClient.GetDomain ( "example.com" ); 10 | ``` 11 | 12 | Get your API key by creating a free account at BuiltWith and visiting https://api.builtwith.com 13 | 14 | ### Installing 15 | 16 | Download and build or 17 | 18 | ``` 19 | dotnet add package BuiltWith 20 | ``` 21 | 22 | https://www.nuget.org/packages/BuiltWith/ 23 | 24 | 25 | ## Supported Endpoints 26 | 27 | - [x] [Domain API](https://api.builtwith.com/domain-api) 28 | - [ ] [Free API](https://api.builtwith.com/free-api) 29 | - [ ] [Lists API](https://api.builtwith.com/lists-api) 30 | - [ ] [Relationships API](https://api.builtwith.com/relationships-api) 31 | - [ ] [Keywords API](https://api.builtwith.com/keywords-api) 32 | - [ ] [Trends API](https://api.builtwith.com/trends-api) 33 | - [ ] [Company to URL API](https://api.builtwith.com/company-to-url) 34 | 35 | ## Dependencies 36 | 37 | * .NETStandard 2.0 38 | * Newtonsoft.Json (>= 12.0.3) 39 | 40 | 41 | ## Licence 42 | MIT 43 | 44 | ## Authors 45 | Gary Brewer --------------------------------------------------------------------------------